Instant Message Push Notification Using Sinch not coming on iOS

霸气de小男生 提交于 2019-12-02 16:48:20

问题


[![enter image description here][1]][1]I've mentioned all the fields but still I'm not getting the push notification. This is my code:

Firstly in didFinishLaunchingWithOptions I call this:

        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)
    }

I've also uploaded the push certificate in my sinch dashboard.

May I know what am I missing in this code that might be the reason I'm not getting push.

EDITED:

Here is the image of the uploaded push distribution certificate on Sinch Dashboard.

http://i.stack.imgur.com/d6PVb.png


回答1:


You should not have client?.setSupportPushNotifications(true) thats for when you want to handle the push your self



来源:https://stackoverflow.com/questions/37577566/instant-message-push-notification-using-sinch-not-coming-on-ios

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