didUpdatePushCredentials not get called

后端 未结 4 1363
温柔的废话
温柔的废话 2021-01-18 07:28

I want to implement VoIP notifications in my iOS application, But the didUpdatePushCredentials method never got called, I can\'t get the device token.

4条回答
  •  借酒劲吻你
    2021-01-18 08:11

    Use below code and Make sure about following things.

    **`**// Register for VoIP notifications**`**
    
    - (void) voipRegistration {
        dispatch_queue_t mainQueue = dispatch_get_main_queue();
        // Create a push registry object
        _voipRegistry = [[PKPushRegistry alloc] initWithQueue: mainQueue];
        // Set the registry's delegate to self
        [_voipRegistry setDelegate:(id _Nullable)self];
        // Set the push type to VoIP
        _voipRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
    }
    

    Call Below method in didFinishLaunchingWithOptions

    Other deleget method as follow

    - (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials: (PKPushCredentials *)credentials forType:(NSString *)type {
        // Register VoIP push token (a property of PKPushCredentials) with server
    
        if([credentials.token length] == 0) {
            NSLog(@"voip token NULL");
            return;
        }
        NSLog(@"%@",credentials.token);
    }
    

    //Make sure about this in project capabilities

    1)Background mode is ON

    2)VOIP

    3)Background Fetch

    4)remotenotification

    5) Dont forgot to import delegate

    inside the Background MODE

提交回复
热议问题