Skip to content
This repository was archived by the owner on Sep 4, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
<activity android:name="com.adobe.phonegap.push.PushHandlerActivity" android:exported="true" android:permission="${applicationId}.permission.PushHandlerActivity"/>
<receiver android:name="com.adobe.phonegap.push.BackgroundActionButtonHandler"/>
<receiver android:name="com.adobe.phonegap.push.PushDismissedHandler"/>
<service android:name="com.adobe.phonegap.push.FCMService">
<service android:name="com.adobe.phonegap.push.FCMService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service android:name="com.adobe.phonegap.push.PushInstanceIDListenerService">
<service android:name="com.adobe.phonegap.push.PushInstanceIDListenerService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
Expand Down
9 changes: 9 additions & 0 deletions src/ios/PushPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ - (void)unregister:(CDVInvokedUrlCommand*)command;
NSLog(@"unsubscribe from topic: %@", topic);
[pubSub unsubscribeFromTopic:topic];
}
} 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 {
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?

[[UIApplication sharedApplication] unregisterForRemoteNotifications];
[self successWithMessage:command.callbackId withMsg:@"unregistered"];
Expand Down