【问题标题】:Turn on/off vibration and sound while receiving remote notification ios swiftios swift接收远程通知时打开/关闭振动和声音
【发布时间】:2017-05-02 05:21:37
【问题描述】:

我的应用中有设置,我有一个切换按钮,用于打开打开关闭声音振动 也是如此,同时接收远程通知。下面是我在AppDelegate注册远程通知的代码

let notificationTypes: UIUserNotificationType = [UIUserNotificationType.Alert, UIUserNotificationType.Sound]
    let pushNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)
    application.registerUserNotificationSettings(pushNotificationSettings)
    application.registerForRemoteNotifications()

对于声音,我提到了这个Remove sound from notification,但它似乎不起作用。

Whatsapp 有这个功能,所以肯定有可能

谁能给点建议?

【问题讨论】:

    标签: ios swift audio vibration remote-notifications


    【解决方案1】:

    请从 JSON 有效负载中删除正确的键值。

    我刚刚检查过了。它对我有用。

    {"aps":{"alert":"Enter your message","badge":1}}
    

    【讨论】:

    • 谢谢 :-) 它有效。您对振动有任何想法吗?
    • 当手机处于响铃模式时,我没有震动。
    • 是的,但是如果在手机设置中打开了振动,它就会振动,否则它不会振动。有没有办法在我们的应用程序中处理振动?我在 Whatsapp 看到过这个
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多