1
我不能让Apple推送通知在开发模式下工作。当目标设备处于后台模式时,永不会在源设备上调用shouldSendPushNotifications方法。如果两个设备都处于前景模式,我已将我的APN开发证书上载到Sinch仪表板,并且即时消息传递工作正常。我有一个有效的设备令牌,我正在使用自己的推送消息。这里是我的代码:Sinch APN shouldSendPush Notifications never called
sinCli = Sinch.clientWithApplicationKey("XXXX", applicationSecret: "XXXX", environmentHost: "sandbox.sinch.com", userId: sinchUserId)
sinCli.delegate = self
sinCli.setSupportMessaging(true)
if let deviceToken = defaults.dataForKey(Globals.KEY_APN_DEVICE_TOKEN)
{
sinCli.setSupportPushNotifications(true)
sinCli.registerPushNotificationDeviceToken(deviceToken, type: SINPushTypeRemote, apsEnvironment: SINAPSEnvironment.Development)
sinCli.setPushNotificationDisplayName("MyApp")
}
sinCli.start()
sinCli.startListeningOnActiveConnection()
sinCli.messageClient().delegate = self
我忘记了什么吗?
我现在使用SinchService框架,而不是SINClient,它工作正常 – Tamas
酷,可以标记为答案请? – cjensen
是的,但我仍想解决一个问题:在我的设置中,我可以关闭推送通知,但由于SinchService仅适用于启用推送通知,所以如果用户在设置中禁用推送通知,则必须使用SINClient。这有点麻烦,如果我可以在两种情况下使用SinchService,会更好。 – Tamas