ios 本地推送的声音、震动

iOS 码拜 9年前 (2015-05-02) 2432次浏览 0个评论

新手上路~~开发中有一个需求,用UISwitch分别对app本地推送时的声音震动有一个开、关的设置, 怎么实现呢???

ios 本地推送的声音、震动
40分
如果是本地通知的话,你实例化一个UILocalNotification的时候,不给它设置声音震动就好了。
远程通知的话,你需要把用户的选择同步到服务器,根据https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1文档的描述,

引用

If the sound file doesn’t exist or default is specified as the value, the default alert sound is played.

如果服务器不提供sound key的话,就没有声音,也不会震动,类似于这样的json:
{“aps”:{“alert”:{“loc-key”:”SOME_KEY”}, “badge”:1}

如果只想要声音,不要震动的话,应该只能让用户在手机设置里关闭震动

ios 本地推送的声音、震动
引用 1 楼 zhangao0086 的回复:

如果是本地通知的话,你实例化一个UILocalNotification的时候,不给它设置声音震动就好了。
远程通知的话,你需要把用户的选择同步到服务器,根据https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1文档的描述,

引用

If the sound file doesn’t exist or default is specified as the value, the default alert sound is played.

如果服务器不提供sound key的话,就没有声音,也不会震动,类似于这样的json:
{“aps”:{“alert”:{“loc-key”:”SOME_KEY”}, “badge”:1}

如果只想要声音,不要震动的话,应该只能让用户在手机设置里关闭震动。

我找到了soundname 设置为了空 可以让它没有声音 那么震动该怎么办呢?我没有找到有关震动的属性~~

ios 本地推送的声音、震动
引用 2 楼 warm92 的回复:
Quote: 引用 1 楼 zhangao0086 的回复:

如果是本地通知的话,你实例化一个UILocalNotification的时候,不给它设置声音和震动就好了。
远程通知的话,你需要把用户的选择同步到服务器,根据https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1文档的描述,

引用

If the sound file doesn’t exist or default is specified as the value, the default alert sound is played.

如果服务器不提供sound key的话,就没有声音,也不会震动,类似于这样的json:
{“aps”:{“alert”:{“loc-key”:”SOME_KEY”}, “badge”:1}

如果只想要声音,不要震动的话,应该只能让用户在手机设置里关闭震动。

我找到了soundname 设置为了空 可以让它没有声音 那么震动该怎么办呢?我没有找到有关震动的属性~~

震动也是一个souond:kSystemSoundID_Vibrate


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明ios 本地推送的声音、震动
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!