SWIFT: I don't get notifications from my CloudKit app?

强颜欢笑 提交于 2019-12-07 15:57:30
Akshansh Thakur

In your app Delegate, you are missing this method :

func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {

    print(deviceToken)       // This is the device token
    var token: String = "\(deviceToken)"    /// formatted token.

    let rawtoken = token.stringByReplacingOccurrencesOfString(">", withString: "")
    let cleantoken = rawtoken.stringByReplacingOccurrencesOfString("<", withString: "")
    var finaltoken = cleantoken.stringByReplacingOccurrencesOfString(" ", withString: "")
    // Send device token to server

            }
        }
    }

WHat I mean is that to send notification, you register user for push Notification. For the case If the register succeeds, you have to implement the method above. if the registeration fails, you have to implement this :

 func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
    print(error)

}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!