[英]Push notifications don't vibrate and are silent
I have created push notifications using Parse which are successfully sent to my device (real-world, not a simulator). 我使用Parse创建了推送通知,这些通知已成功发送到我的设备(真实世界,而不是模拟器)。 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.
如果手机处于锁定状态,并且手机处于开机状态但未运行应用程序,则属于这种情况。
I have code in the didReceiveRemoteNotification:
method to play a sound, which is played when the app is running. 我在
didReceiveRemoteNotification:
方法中有代码来播放声音,该声音在应用程序运行时播放。 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? 但是,当应用程序未运行时设备收到推送通知时,如何播放声音并让手机振动?
Fixed by sending the sounds file through an NSDictionary
, as shown in the parse documention . 通过通过
NSDictionary
发送声音文件进行了修复,如解析文档中所示。
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];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.