- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试使用 GCM 唤醒手机或让指示灯闪烁。我收到的消息很好,但设置高优先级或根本没有设置没有区别。我正在使用 razr maxx hd 进行测试。我在这里遗漏了什么吗?
<?php
// API access key from Google API's Console
define('API_ACCESS_KEY', 'blee');
// prep the bundle
$msg = array
(
'body' => 'this is my nice body',
'sound' => 'misc/androidnotification.mp3',
'custom' => array(
'route' => '/beee'
)
);
$fields = array
(
'collapse_key' => 'test',
"time_to_live" => 0,
'priority' => 'high',
'to' => 'mykey',
'data' => $msg,
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, 'https://android.googleapis.com/gcm/send' );
curl_setopt( $ch,CURLOPT_POST, true );
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
$result = curl_exec($ch );
curl_close( $ch );
echo $result;
最佳答案
来自以下两个链接
Optimizing for Doze and App Standby
你可以推断出高优先级消息
GCM attempts to deliver high priority messages immediately, allowing the GCM service to wake a sleeping device when possible and open a network connection to your app server.
对于普通消息
Normal priority messages won't open network connections on a sleeping device, and their delivery may be delayed to conserve battery.
正如您可以从以下 question 的答案中看到的那样
对于低于 Marshmallow 的 Android 版本,您永远无法确定 Android 设备是否处于 sleep 模式,对于运行 Marshmallow 或更高版本的设备,存在打瞌睡模式。
因此,获取运行 Marshmallow 或更高版本的设备,并通过运行以下命令将其置于剂量模式
$ adb shell dumpsys battery unplug
$ adb shell dumpsys deviceidle step
您可能需要多次运行第二个命令。重复直到设备状态变为空闲。
现在尝试发送具有高优先级和普通优先级的推送通知。当消息优先级高时,应该收到通知,类似地,当没有设置优先级或设置为正常时,通知将延迟一段时间或在您唤醒设备时发送。
关于php - Android - 谷歌云消息传递的高优先级消息(使用 corona sdk),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36168150/
由于某些原因,如果 else 语句执行太多次,下面的代码会抛出堆栈溢出错误。我试图让 scene.targeting 函数从参数中传递的 objTable 中选择一个目标,但只有带有 .tgtFlag
我希望使用Corona sdk来开发一款新游戏。但我找不到播放mp3文件的api。Corona sdk支持播放mp3流吗? 欢迎大家留言 最佳答案 实际上,media.playSound() 已被弃用
我为 Corona SDK 构建了以下应用程序 local hello = "hello"; print(hello); 使用 iPhone 作为目标..最终的二进制文件大小达到惊人的
我尝试在场景中拖动重力 = 0,0 的动态主体,我有一个主体类型为动态的正方形,以及一个主体类型为静态的图像,但是当将方形拖动到图像上时,会出现一个力量不大,但可以超出图像并传递到另一边,如图所示:
我目前正在使用Corona SDK开发一款小游戏。我最近开始在游戏中添加音频/声音-fx。所有音频都可以在模拟器,PC和平板电脑上正常工作。但是,当我在Galaxy s7上玩游戏时,音频根本无法执行任
我目前正在制作一个非常简单的应用程序,在该应用程序中,点击图像时会播放声音,某些文本会记录点击次数。但是,我注意到音频中存在一些明显的延迟,在单击图像后,音频将需要半秒钟才能播放。有谁知道为什么会这样
我在模拟器中遇到此错误: main.lua:24:audio.loadSound()无法创建声音“1.wav” 声音正确无误 这是我的代码: (我已经更改了声音的名称和本地名称,但没有用) 我在这里有
我想使用 Corona SDK 制作一个声音合成器,这意味着在纯 Lua 中。所有的 Lua synth 程序都依赖于一个底层的 C 程序。有没有生成波形的Lua库? 最佳答案 我没有音频方面的经验。
好的,我有一个非常非常大的背景图像,不是图像而是蓝色的矩形: bg2 =display.newRect(0,0,20000,20000) bg2.y=10000 bg2:setFillColor( 0
我在 corona sdk 中做了一个简单的游戏。现在我想让它成为一个分屏多人游戏。我想将我的单人游戏用作单元游戏。然后我想在同一设备的两个部分运行两个不同的单元。 但我找不到任何有效的方法来做到这一
我正在用力击球,有一堵墙被分配了物理属性并且是静态的,但球是动态的,问题是当足够的力施加到球上时,它穿过墙,它是简单台球游戏示例中的一种 table 墙。我用过 ball.isBullet=true
我想知道如何使用 Corona 获取图像大小而不加载它们并调用 obj.width。 有办法吗? 最佳答案 如果您的图片是 PNG,是的! http://developer.coronalabs.co
我得到了一张小瓷砖图片。我想用该图像设置背景,我想重复图像以填充整个背景。例如,在 CSS 中,我们使用 repeat-x 和 repeat-y 属性重复背景图像。 最佳答案 你应该得到图像的宽度和高
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 去年关闭。 Improve this
我想知道在为 iOS 构建时,是否有任何原因导致 corona 无法完成“执行构建”。我知道互联网连接不佳(我碰巧没有)会减慢它的速度——但不会达到我需要让我的电脑运行几个小时的程度...... 不久
我想添加自定义方法来显示对象,类似于预建方法,例如“setFillColor” 我写了下面的代码,但没有用;然而,它解释了我需要什么 function display:foo(bar) pri
出于发布原因,这里是我正在尝试做的一个简单版本。 在屏幕上,我有一个简单的圆形对象,它是静态的,不会移动。然后用户可以拖放一条直线。如果这条线穿过那个圆圈,我希望触发碰撞事件。 似乎除非其中一个物体在
我对电晕中的自定义形状有一些麻烦。 这是我的代码,它的作用是我在场景中添加了一些球体,以便它们落入篮子内,这个篮子是我在 newBasket() 函数中定义的自定义形状对象,问题是篮子确实与地面物体碰
我使用 Corona-SDK 制作了一个游戏。它有2个场景:(1)菜单场景和(2)游戏场景。 我需要我的应用程序支持两个方向:“landscapeRight”和“landscapeLeft”。 为此,
我正在制作一个使用物理的游戏。我有一个球,当它到达某个区域时,说 ball.x > 100 and ball.x 100 and ball.y < 110 我希望那个球的线速度减慢,但不要停止。我
我是一名优秀的程序员,十分优秀!