【问题标题】:iOS 12 Push Notifications are not working and working in below versions , Push notification not receiving in iOS 12iOS 12 推送通知在以下版本中不起作用,在 iOS 12 中未收到推送通知
【发布时间】:2019-02-28 23:55:24
【问题描述】:

对于 iOS 12,推送通知无法正常工作并在以下版本中工作

我的应用在 Appstore 中。推送通知在 iOS 11 中运行良好,但在 iOS 12 中无法正常工作。我没有收到 iOS 12 设备的任何推送通知。我已经检查了我的服务器中的设备令牌和证书。全部正确。我还检查了设置应用程序中的通知属性。一切都很好。但我没有收到任何通知。

这是我用于推送通知的代码。

你能告诉我会是什么问题吗?如何解决这个问题?

func registerForPushNotifications() {

    if #available(iOS 10.0, *){

        let center = UNUserNotificationCenter.current()
        center.delegate = self
        center.requestAuthorization(options:[.badge, .alert, .sound]) { (granted, error) in
            if (granted)
            {
                UIApplication.shared.registerForRemoteNotifications()
            }
            else{
                //Do stuff if unsuccessful...
                 UIApplication.shared.registerForRemoteNotifications()
            }
            // Enable or disable features based on authorization.
        }
    }
    else
    {

        let types: UIUserNotificationType = [UIUserNotificationType.badge, UIUserNotificationType.alert, UIUserNotificationType.sound]
        let settings: UIUserNotificationSettings = UIUserNotificationSettings( types: types, categories: nil )
        UIApplication.shared.registerUserNotificationSettings( settings )
        UIApplication.shared.registerForRemoteNotifications()

    }

}



@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {

    let userInfo = response.notification.request.content.userInfo as NSDictionary

    print(userInfo)


}

【问题讨论】:

  • 看到这个寻求帮助:stackoverflow.com/questions/39382852/…
  • @Anbu.karthik 推送通知在后台和前台的 iOS 12 版本以下均有效,此问题仅适用于 iOS 12。
  • 给点时间,我会检查并更新你
  • 您找到解决问题的方法了吗?
  • @SandeepBaddula 你找到解决办法了吗?

标签: ios swift apple-push-notifications ios12


【解决方案1】:

当我的应用程序在“调试”中运行时,我遇到了同样的问题,
我在“发布”中运行应用程序并且通知工作正常

【讨论】:

  • 嗨,对我来说,推送通知也不起作用,如果我们从 xcode 构建项目,它就不起作用,如果我从命令提示符构建项目,那么通知就会到来。我在 ionic 框架版本 3 中使用 firebase 推送通知。我将我的 mac ios 版本更新为 12,将 xcode 版本更新为 10,然后通知停止工作..有什么帮助解决这个问题...
猜你喜欢
  • 2019-06-22
  • 2023-02-14
  • 2022-07-27
  • 2017-01-23
  • 1970-01-01
  • 1970-01-01
  • 2021-02-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多