2017-06-13 97 views
0

因此,我呼籲:didUpdatePushCredentials從未被稱爲在IOS 10.2

self.pushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];

它適用於iOS 9,10.0.2和10.3。 didUpdatePushCredentials被調用並且一切正常。然而,對於ios 10.2,它永遠不會被調用,並且整個voip功能不起作用。你能不能告訴它有什麼問題?

PS:設置IP語音和遠程通知功能。

回答

0

參考的ObjectiveC代碼pushkit整合

AppDelegate.h

#import <UIKit/UIKit.h> 
#import <PushKit/PushKit.h> 

@interface AppDelegate : UIResponder <UIApplicationDelegate,PKPushRegistryDelegate> 
{ 
    PKPushRegistry *pushRegistry; 
} 

@property (strong, nonatomic) UIWindow *window; 

@end 

AppDelegate.m

#import "AppDelegate.h" 

@interface AppDelegate() 

@end 

@implementation AppDelegate 


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 


    pushRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()]; 
    pushRegistry.delegate = self; 
    pushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP]; 

    return YES; 
} 

#define PushKit Delegate Methods 

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

    NSLog(@"PushCredentials: %@", credentials.token); 
} 

- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type 
{ 
    NSLog(@"didReceiveIncomingPushWithPayload"); 
} 
@end 

Code for ObjectiveC

Reference

+0

它適合你嗎?如果是,那麼你可以接受答案。 – Hasya

+0

不是。正如我上面提到的,在我的情況下,通知不僅僅在iOs 10.2中工作。你有一些特定的代碼行嗎?如果是的話,你可以參考他們嗎? –

+0

隨着Pushkit,沒有什麼具體的iOS 10.2,我建議一旦交叉驗證您的代碼與https://github.com/hasyapanchasara/PushKit_SilentPushNotification – Hasya