相关疑难解决方法(0)

实现PushKit并测试开发行为

我想在我的应用程序(Voip应用程序)中实现PushKit服务,但我有以下疑问:我看到我只能生成生产voip证书,如果我尝试在开发设备上测试voip推送通知服务,它是否有效?

这是我的实施测试:

使用这3行代码,我可以在didUpdatePushCredentials回调中获取push令牌,用于保存到我的服务器中.

PKPushRegistry *pushRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
pushRegistry.delegate = self;
pushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
Run Code Online (Sandbox Code Playgroud)

服务器端我生成一个只有警报文本的"正常"有效负载推送通知,然后我发送到存储在我服务器中的voip令牌.

我使用带有调试日志的回调,但它们永远不会被调用!

- (void)pushRegistry:(PKPushRegistry *)registry didInvalidatePushTokenForType:(NSString *)type {

          NSLog(@"didInvalidatePushTokenForType");

}

-(void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type {

          NSLog(@"didReceiveIncomingPushWithPayload: %@", payload.description);

}

-(void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type {
     if([credentials.token length] == 0) {
           NSLog(@"voip token NULL");

          return;
     }

      NSLog(@"didUpdatePushCredentials: %@ - Type: %@", credentials.token, type);

}
Run Code Online (Sandbox Code Playgroud)

如果我尝试从我的服务器生成推送通知消息,以便先前上传的voip设备令牌,我从未通知didReceiveIncomingPushWithPayload回调,但是从服务器我得到200 ok消息(消息已成功发送)

apple-push-notifications ios ios-frameworks ios8

21
推荐指数
2
解决办法
3万
查看次数