简体   繁体   English

在某些情况下只发出没有声音的通知

[英]push notifications with NO sound JUST in some situations

The app is registered to receive all the 3 kinds of notifications (badge, alert, sound). 该应用程序已注册,可以接收所有3种通知(徽章,警报,声音)。

I want that push notifications be with NO sound in background JUST IN some situations (in the app user click a button to disable notifications) and to allow the sound for all the other cases. 我希望在某些情况下推送通知在后台不发出声音(在应用程序用户中,单击按钮以禁用通知),并在所有其他情况下允许发出声音。

Do you have some ideas? 你有什么主意吗? Thanks 谢谢

From Apple's Remote Notification Guide: 从Apple的远程通知指南中:

The aps dictionary can also contain the content-available property. aps词典也可以包含content-available属性。 The content-available property with a value of 1 lets the remote notification act as a “silent” notification. 值为1的内容可用属性使远程通知充当“静默”通知。 When a silent notification arrives, iOS wakes up your app in the background so that you can get new data from your server or do background information processing. 当收到静默通知时,iOS会在后台唤醒您的应用程序,以便您可以从服务器获取新数据或进行后台信息处理。 Users aren't told about the new or changed information that results from a silent notification, but they can find out about it the next time they open your app. 不会通知用户有关静默通知产生的新信息或更改信息,但是下次打开应用程序时,他们可以找到有关信息。

To support silent remote notifications, add the remote-notification value to the UIBackgroundModes array in your Info.plist file. 若要支持静默远程通知,请将远程通知值添加到Info.plist文件中的UIBackgroundModes数组。 To learn more about this array, see UIBackgroundModes in Information Property List Key Reference. 要了解有关此数组的更多信息,请参见《信息属性列表键参考》中的UIBackgroundModes。

Depending on your model (assuming a system like Parse or something), store the user's preference in the cloud and, when generating your PUSH notifications, decide whether to add this flag or not. 根据您的模型(假设系统为Parse之类),将用户的首选项存储在云中,并在生成PUSH通知时决定是否添加此标志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM