推送通知不振动且静音 [英] Push notifications don't vibrate and are silent

查看:70
本文介绍了推送通知不振动且静音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Parse 创建了推送通知,这些通知已成功发送到我的设备(真实世界,而不是模拟器).但是,这些推送通知是默默出现的,不会振动我的手机,也不会发出任何声音来通知用户.如果手机已锁定,并且手机处于开机状态,但未运行应用程序,则属于这种情况.

I have created push notifications using Parse which are successfully sent to my device (real-world, not a simulator). However, these push notifications appear silently, not vibrating my phone, nor making any sound to notify the user. This is the case if the phone is locked, and when the phone is on, but not running the app.

我在 didReceiveRemoteNotification: 方法中有代码来播放声音,在应用程序运行时播放.但是,当设备在应用未运行的情况下收到推送通知时,如何播放声音并使手机振动?

I have code in the didReceiveRemoteNotification: method to play a sound, which is played when the app is running. However, how can I play a sound, and get my phone to vibrate, when the device receives a push notification whilst the app is not running?

推荐答案

通过 NSDictionary 发送声音文件来修复,如 解析文档.

Fixed by sending the sounds file through an NSDictionary, as shown in the parse documention.

NSDictionary *data = @{
  @"alert" : @"Jet fuel proven to melt steal beams!",
  @"badge" : @"Increment",
  @"sounds" : @"cheering.caf"
};
PFPush *push = [[PFPush alloc] init];
[push setChannels:@[ @"Dank_Memes" ]];
[push setData:data];
[push sendPushInBackground];

这篇关于推送通知不振动且静音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆