Skip to content
This repository was archived by the owner on Sep 4, 2020. It is now read-only.
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/ios/PushPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,16 @@ - (void)unregister:(CDVInvokedUrlCommand*)command;
NSLog(@"unsubscribe from topic: %@", topic);
[pubSub unsubscribeFromTopic:topic];
}
} else {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding an else if what about putting that code inside the else statement? So…

    else {
        if ([self usesFCM]) {
            [[FIRInstanceID instanceID] deleteIDWithHandler:^void(NSError *_Nullable error){
                if (error) {
                    [self failWithMessage:command.callbackId withMsg:@"" withError:error];
                } else {
                    [self successWithMessage:command.callbackId withMsg:@"unregistered"];
                }
            }];
        }
        [[UIApplication sharedApplication] unregisterForRemoteNotifications];
        [self successWithMessage:command.callbackId withMsg:@"unregistered"];
    }

This way the APNS token will get released as well.

Copy link
Copy Markdown
Contributor Author

@malwatte malwatte Aug 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Let me do that.
I do not know how APNS token works. Thats why I put inside an else. hehe.

Copy link
Copy Markdown
Contributor Author

@malwatte malwatte Aug 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it and there is a small problem. Success callback gets called even when FCM token delete failed. So I did something like this,

} else if ([self usesFCM]){
        [[FIRInstanceID instanceID] deleteIDWithHandler:^void(NSError *_Nullable error){
            if (error) {
                [self failWithMessage:command.callbackId withMsg:@"" withError:error];
            } else {
                [[UIApplication sharedApplication] unregisterForRemoteNotifications];
                [self successWithMessage:command.callbackId withMsg:@"unregistered"];
            }
        }];
} else {
        [[UIApplication sharedApplication] unregisterForRemoteNotifications];
        [self successWithMessage:command.callbackId withMsg:@"unregistered"];
}

Should be fine. Right?

Copy link
Copy Markdown
Contributor Author

@malwatte malwatte Aug 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@macdonst
Are the changes ok?

} else if ([self usesFCM]){
[[FIRInstanceID instanceID] deleteIDWithHandler:^void(NSError *_Nullable error){
if (error) {
[self failWithMessage:command.callbackId withMsg:@"" withError:error];
} else {
[self successWithMessage:command.callbackId withMsg:@"unregistered"];
}
}];
}
else {
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
[self successWithMessage:command.callbackId withMsg:@"unregistered"];
}
Expand Down