是否可以发送推送通知而不是振动设备

时间:2014-07-16 16:30:20

标签: ios objective-c push-notification

我正在尝试向设备发送“静音”推送通知,但不会将任何内容放到屏幕上,但会触发从服务器重新加载某些信息。

我已停止在屏幕上显示任何内容而未设置alert,但设备在收到通知时仍会振动但仅在应用正在运行时才会振动。

当应用程序运行并收到通知时,是否可以阻止应用程序振动?

3 个答案:

答案 0 :(得分:1)

如果您完全从警报中删除声音,则不会播放任何声音,如果您的应用已关闭,则您的手机不会振动。

但是,如果应用程序处于打开状态,手机仍会振动。

不幸的是,无法禁用它。

答案 1 :(得分:0)

导致设备振动的[PFPush handlePush:userInfo]

如果您愿意使用[PFPush handlePush:userInfo]放弃并使用自己的代码处理推送通知,那么就不必振动。

答案 2 :(得分:0)

发生在我身上。也许它会帮助你。检查你的代码,可以让手机振动调用AudioServicesPlaySystemSound方法。

/**
* Remote Notification Received while application was open.
*/
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    #if !TARGET_IPHONE_SIMULATOR
    NSString *sound = [apsInfo objectForKey:@“sound”];
    NSLog(@“Received Push Sound: %@”, sound);
    // Vibrate happen here!!
    AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
    #endif
}

或检查您的通知有效负载。将声音设置为空或只是将其删除。

{"aps":{"content-available":1, "sound":"", "badge":1}}
相关问题