From de284fcfb645ef37b4637e8fb598ec19583ba075 Mon Sep 17 00:00:00 2001 From: REIS Benjamin Date: Tue, 13 Sep 2016 14:24:52 +0200 Subject: [PATCH] received pushkit crendential in main queue --- Classes/LinphoneAppDelegate.m | 28 ++++++++++++++++------------ Classes/LinphoneManager.m | 1 - 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index c56e34691..b3347921a 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -155,7 +155,7 @@ answer.activationMode = UIUserNotificationActivationModeForeground; answer.destructive = NO; answer.authenticationRequired = YES; - + UIMutableUserNotificationAction *decline = [[UIMutableUserNotificationAction alloc] init]; decline.identifier = @"decline"; decline.title = NSLocalizedString(@"Decline", nil); @@ -204,7 +204,7 @@ #pragma deploymate pop - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - UIApplication *app = [UIApplication sharedApplication]; + UIApplication *app = [UIApplication sharedApplication]; UIApplicationState state = app.applicationState; LinphoneManager *instance = [LinphoneManager instance]; @@ -233,12 +233,15 @@ [RootViewManager setupWithPortrait:(PhoneMainView *)self.window.rootViewController]; [PhoneMainView.instance startUp]; [PhoneMainView.instance updateStatusBar:nil]; - - NSDictionary *remoteNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; - if (remoteNotif) { - LOGI(@"PushNotification from launch received."); - [self processRemoteNotification:remoteNotif]; - } + + if (floor(NSFoundationVersionNumber) < NSFoundationVersionNumber_iOS_8_0) { + NSDictionary *remoteNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; + if (remoteNotif) { + LOGI(@"PushNotification from launch received."); + [self processRemoteNotification:remoteNotif]; + } + } + if (bgStartId != UIBackgroundTaskInvalid) [[UIApplication sharedApplication] endBackgroundTask:bgStartId]; @@ -249,7 +252,8 @@ [application registerUserNotificationSettings:notificationSettings]; //output what state the app is in. This will be used to see when the app is started in the background - NSLog(@"app launched with state : %li", (long)application.applicationState); + LOGI(@"app launched with state : %li", (long)application.applicationState); + LOGI(@"FINISH LAUNCHING WITH OPTION : %@", launchOptions.description); return YES; } @@ -452,7 +456,7 @@ - (void)pushRegistry:(PKPushRegistry *)registry didInvalidatePushTokenForType:(NSString *)type { LOGI(@"PushKit Token invalidated"); - [LinphoneManager.instance setPushNotificationToken:nil]; + dispatch_async(dispatch_get_main_queue(), ^{[LinphoneManager.instance setPushNotificationToken:nil];}); } - (void)pushRegistry:(PKPushRegistry *)registry @@ -461,7 +465,7 @@ didInvalidatePushTokenForType:(NSString *)type { LOGI(@"PushKit received with payload : %@", payload.description); LOGI(@"incoming voip notfication: %@ ", payload.dictionaryPayload); - dispatch_async(dispatch_get_main_queue(), ^{[self processRemoteNotification:payload.dictionaryPayload];}); + //dispatch_async(dispatch_get_main_queue(), ^{[self processRemoteNotification:payload.dictionaryPayload];}); } - (void)pushRegistry:(PKPushRegistry *)registry @@ -470,7 +474,7 @@ didInvalidatePushTokenForType:(NSString *)type { LOGI(@"PushKit credentials updated"); LOGI(@"voip token: %@", (credentials.token)); LOGI(@"%@ : %@", NSStringFromSelector(_cmd), credentials.token); - [LinphoneManager.instance setPushNotificationToken:credentials.token]; + dispatch_async(dispatch_get_main_queue(), ^{[LinphoneManager.instance setPushNotificationToken:credentials.token];}); } #pragma mark - User notifications diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 0987476b0..3b40fa873 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -616,7 +616,6 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char } - (void)onCall:(LinphoneCall *)call StateChanged:(LinphoneCallState)state withMessage:(const char *)message { - // Handling wrapper LinphoneCallAppData *data = (__bridge LinphoneCallAppData *)linphone_call_get_user_data(call); if (!data) {