diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index c34381278..65e996b48 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -81,6 +81,7 @@ - (void)applicationWillEnterForeground:(UIApplication *)application { LOGI(@"%@", NSStringFromSelector(_cmd)); + [LinphoneManager.instance startLinphoneCore]; [LinphoneManager.instance.fastAddressBook reloadFriends]; @@ -486,13 +487,13 @@ didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { LOGI(@"[APNs] %@ : %@", NSStringFromSelector(_cmd), deviceToken); dispatch_async(dispatch_get_main_queue(), ^{ - [LinphoneManager.instance setRemoteNotificationToken:deviceToken]; + linphone_core_did_register_for_remote_push(LC, (__bridge void*)deviceToken); }); } - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { LOGI(@"[APNs] %@ : %@", NSStringFromSelector(_cmd), [error localizedDescription]); - [LinphoneManager.instance setRemoteNotificationToken:nil]; + linphone_core_did_register_for_remote_push(LC, nil); } #pragma mark - UNUserNotifications Framework diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h index 3244079c2..710338ea6 100644 --- a/Classes/LinphoneManager.h +++ b/Classes/LinphoneManager.h @@ -199,8 +199,6 @@ typedef struct _LinphoneManagerSounds { @property (readonly) const char* backCamId; @property(strong, nonatomic) NSString *SSID; @property (readonly) sqlite3* database; -@property(nonatomic, strong) NSData *pushKitToken; -@property(nonatomic, strong) NSData *remoteNotificationToken; @property (readonly) LinphoneManagerSounds sounds; @property (readonly) NSMutableArray *logs; @property (nonatomic, assign) BOOL bluetoothAvailable; diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index c82a19037..2c922c24e 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1286,14 +1286,18 @@ void popup_link_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreat } - (void)startLinphoneCore { - bool pushEnabled = [self lpConfigIntForKey:@"proxy" inSection:@"push_notification_allowed"]; - linphone_core_set_push_notification_enabled([LinphoneManager getLc], pushEnabled); + bool corePushEnabled = [self lpConfigIntForKey:@"proxy" inSection:@"push_notification_allowed"]; + linphone_core_set_push_notification_enabled([LinphoneManager getLc], corePushEnabled); + linphone_core_start([LinphoneManager getLc]); + const MSList *accountsList = linphone_core_get_account_list(theLinphoneCore); while (accountsList) { LinphoneAccount * account = accountsList->data; LinphoneAccountParams * accountParams = linphone_account_params_clone(linphone_account_get_params(account)); - linphone_account_params_set_push_notification_allowed(accountParams, pushEnabled); - linphone_account_params_set_remote_push_notification_allowed(accountParams, pushEnabled); + // In linphone-iphone, remote and voip push autorisations always go together. + bool accountPushAllowed = linphone_account_params_get_push_notification_allowed(accountParams); + linphone_account_params_set_remote_push_notification_allowed(accountParams, accountPushAllowed); + LinphonePushNotificationConfig *pushConfig = linphone_account_params_get_push_notification_config(accountParams); #ifdef DEBUG @@ -1302,13 +1306,10 @@ void popup_link_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreat #define PROVIDER_NAME "apns" #endif linphone_push_notification_config_set_provider(pushConfig, PROVIDER_NAME); - linphone_account_set_params(account, accountParams); linphone_account_params_unref(accountParams); accountsList = accountsList->next; } - - linphone_core_start([LinphoneManager getLc]); } - (void)createLinphoneCore { @@ -1794,15 +1795,6 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { [CallManager.instance startCallWithAddr:iaddr isSas:FALSE]; } -#pragma mark - Property Functions -- (void)setRemoteNotificationToken:(NSData *)remoteNotificationToken { - if (remoteNotificationToken == _remoteNotificationToken) { - return; - } - _remoteNotificationToken = remoteNotificationToken; - linphone_core_did_register_for_remote_push(LC, (__bridge void*)remoteNotificationToken); -} - #pragma mark - Misc Functions + (PHFetchResult *)getPHAssets:(NSString *)key { PHFetchResult *assets;