Commit 173d9579 authored by QuentinArguillere's avatar QuentinArguillere
Browse files

Remove old code that prevented from registering for remote push notification...

Remove old code that prevented from registering for remote push notification when starting linphone from background, and fix a bug where deactivating the push notification for a specific account wasn’t saved when going restarting the app
parent fbf2b92f
Pipeline #29640 passed with stage
in 5 minutes and 20 seconds
......@@ -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
......
......@@ -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;
......
......@@ -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<PHAsset *> *assets;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment