【问题标题】:Vibrate on push notification in iOS depend on client side or payloadiOS中推送通知的振动取决于客户端或有效负载
【发布时间】:2020-05-08 13:40:07
【问题描述】:

以下是我的请求通知代码

if #available(iOS 10, *) {
        UNUserNotificationCenter.current().requestAuthorization(options:[.badge, .alert, .sound]){ (granted, error) in }
        application.registerForRemoteNotifications()
    }

我已在通知中要求用户授予声音、警报和徽章权限。 我还浏览了以下有关推送通知振动的链接。

vibrate in push notification

我的问题是应用程序关闭时的推送通知振动是由应用程序处理的,或者是使 iPhone 振动的有效负载。

是否可以通过推送通知来处理 iPhone 的振动,例如推送通知有效载荷中的声音键,或者是否有任何其他方式来控制推送振动?

提前致谢

【问题讨论】:

    标签: ios swift push-notification


    【解决方案1】:

    您实际上可以通过指定声音来控制有效载荷内的振动。如果您指定自己的声音,可能没有振动,但如果您只使用默认声音,设备会振动!

    示例负载:

    {
        "aps" : {
            "alert" : "You got your emails.",
            "badge" : 9,
            "sound" : "bingbong.aiff" // or set this to the default sound
        }
    }
    

    【讨论】:

      【解决方案2】:

      你不能。

      要在手机上触发振动,您需要:

      • 在您的有效负载中,您需要在 aps 键下的 sound 字段
      • 设备需要启用振动。

      显然你无法通过有效载荷控制手机的振动

      【讨论】:

      • {"aps":{ "alert":"rich notification", "mutable-content":1, "badge":1, "sound": "default" }, "mediaUrl": "simform.com/static/adopting-process-men.png", } 这是有效载荷,但我的手机没有振动
      • 查看来自here 的样本负载。 “声音”必须是“aps”键的字段。你在“警报”键下有你的。如果您在问题中包含该有效负载也会更好。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-23
      • 1970-01-01
      • 2018-04-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多