[![在此处输入图片描述] [1]] [1]我已经提到了所有字段,但我仍然没有收到推送通知。 这是我的代码:
首先在didFinishLaunchingWithOptions中我称之为:
self.push = Sinch.managedPushWithAPSEnvironment(.Production)
self.push?.delegate = self
self.push?.setDesiredPushTypeAutomatically()
client = Sinch.clientWithApplicationKey("xxxxxx", applicationSecret: "xxxxxxx", environmentHost: "sandbox.sinch.com", userId: userID)
client?.delegate = self
client?.setSupportMessaging(true)
client?.setSupportPushNotifications(true)
client?.enableManagedPushNotifications()
client?.start()
client?.startListeningOnActiveConnection()
self.push?.registerUserNotificationSettings()
func managedPush(managedPush: SINManagedPush!, didReceiveIncomingPushWithPayload payload: [NSObject : AnyObject]!, forType pushType: String!) {
self.client?.relayRemotePushNotification(payload)
}
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
let tokenChars = UnsafePointer<CChar>(deviceToken.bytes)
var tokenString = ""
for i in 0..<deviceToken.length {
tokenString += String(format: "%02.2hhx", arguments: [tokenChars[i]])
}
self.push?.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
}
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
self.push?.application(application, didReceiveRemoteNotification: userInfo)
}
我还在我的sinch仪表板中上传了推送证书。
我可能知道我在这段代码中遗漏了什么,这可能是我没有得到推动的原因。
编辑:
以下是Sinch Dashboard上传的推送分发证书的图像。
答案 0 :(得分:0)
你不应该有客户端吗?.setSupportPushNotifications(true)那就是你想要处理推动自己的时候