使用Sinch进行应用程序到应用程序调用的推送通知未到

时间:2018-10-08 11:06:00

标签: ios voip sinch

我正在开发使用Sinch框架进行音频呼叫的应用程序。 我不知道安装过程中会错过什么。当应用程序处于前台时,一切正常。我可以打电话,也可以说话。

但是当应用程序在后台时。我希望收到voip推送通知,但不会收到。

我在Sinch网站上提出了voip证书。 我可以使用knuff接收推送通知

代码

-(void)initSinchClientWithUserId:(NSString *)userId{
sinchClient = [Sinch clientWithApplicationKey:@"3a130480-*****e370f0"
                            applicationSecret:@"XP0E******3Oh2PxCWw=="
                              environmentHost:@"sandbox.sinch.com"
                                       userId:userId];
[sinchClient setSupportCalling:YES];
[sinchClient enableManagedPushNotifications];
sinchClient.delegate =self;
sinchClient.callClient.delegate =self;
[sinchClient start];
[sinchClient startListeningOnActiveConnection];
if (pushTokenData) {
    [sinchClient registerPushNotificationData:pushTokenData];
}

}

设置推送通知

    self.push = [Sinch managedPushWithAPSEnvironment:SINAPSEnvironmentAutomatic];
self.push.delegate = self;
[self.push setDesiredPushTypeAutomatically];
[self.push registerUserNotificationSettings];

保存令牌

- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)pushCredentials forType:(PKPushType)type{

    if (sinchClient) {
        [sinchClient registerPushNotificationData:pushCredentials.token];
    }

}

处理通知,但从未调用

 - (void)managedPush:(id<SINManagedPush>)unused
didReceiveIncomingPushWithPayload:(NSDictionary *)payload
            forType:(NSString *)pushType {

     [self handleRemoteNotification:payload];
}

1 个答案:

答案 0 :(得分:0)

if(pushTokenData){     [sinchClient registerPushNotificationData:pushTokenData]; }

[sinchClient registerPushNotificationData:pushTokenData];应该在获得推送令牌时真正调用,而不是在init或应用启动时调用。

相关问题