【问题标题】:iOS displaying push notifications based on user's locationiOS 根据用户的位置显示推送通知
【发布时间】:2017-02-07 03:17:16
【问题描述】:

我目前正在快速开发一个 iOS 应用程序。该应用程序已经可以接收 APN 通知(其中包含坐标)。我想做的是根据用户与通知数据中包含的坐标指示的位置的距离来决定是否显示通知。有可能这样做吗?如果没有,服务器是否可以在发送 APN 请求之前从应用程序(即使在后台或关闭时)请求用户的位置?

谢谢。

【问题讨论】:

    标签: ios push-notification cllocationmanager apn


    【解决方案1】:

    您可以设置静默推送通知,通知您的程序,而不是用户。有效载荷可以包含您的坐标,您的程序可以读取有效载荷并决定是否需要响应通知。

    【讨论】:

    • 它也会使用 APN 服务吗?
    • 是的。在 Web 或 Xcode 中搜索“iOS 静默推送通知”。有据可查。
    • 如果我设置了静默通知,如何显示横幅?是否可以在后台从应用程序发出本地通知,还是我需要向服务器发出请求才能发送另一个通知,这次是横幅?
    • 嗨 @Gabrielle 在你的 didFinishLaunchingWithOptions 上添加这个:` application.registerUserNotificationSettings(UIUserNotificationSettings(types: [.sound, .alert, .badge], categories: nil)) ` 然后创建本地通知你应该使用:` let notification = UILocalNotification() notification.alertBody = "Your message here" notification.soundName = "Default" UIApplication.shared.presentLocalNotificationNow(notification) `
    猜你喜欢
    • 1970-01-01
    • 2012-07-28
    • 2017-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多