我知道如何创建静默推送通知(播放静音文件)。我也想发送一个不会震动手机的推送通知。
当按照下面的建议设置静音文件时,当手机被锁定或应用程序未激活时,手机仍会振动。
我的有效载荷还在震动:
{
aps = {
alert = {
"loc-key" = "SOME_KEY";
};
badge = 1;
sound = "silence.caf";
};
}这个是可能的吗?
发布于 2014-05-31 18:24:10
省略声音键应该可以解决这个问题:
{"aps":{"alert":{"loc-key":"SOME_KEY"}, "badge":1}The docs声明“如果声音文件不存在或默认值被指定为值,则播放默认的警报声。”他们没有说的是,如果你不提供一个声音键,任何声音都不会被播放。如果没有播放声音,电话也不会振动。
发布于 2014-05-20 15:11:13
我是这样做的:服务器发送一个声音文件名为静默的推送到设备。就这样。
示例:
从服务器传入有效负载:
{ aps = { "content-available" = 1; sound="silence.mp3" }; data-id = 1234; }和设备在AppDelegate中处理它
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
NSInteger data_id= [userInfo[@"data-id"] integerValue];
NSLog(@"Data-id: %i", data_id);
//
// code...
//
// UIBackgroundFetchResultNoData/UIBackgroundFetchResultFailed/UIBackgroundFetchResultNewData
completionHandler(UIBackgroundFetchResultNewData);
}发布于 2014-05-30 04:31:23
当您注册推流通知时,不要询问声音类型(UIRemoteNotificationTypeSound)
- (void)registerForRemoteNotificationTypes:(UIRemoteNotificationType)types您可以通过手动删除通知设置中的声音权限来测试此设置
https://stackoverflow.com/questions/23752957
复制相似问题