Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Callbacks (hasPermission, register) are not called on iOs 13 #2919

Open
sebge2emasphere opened this issue May 31, 2020 · 3 comments
Open

Callbacks (hasPermission, register) are not called on iOs 13 #2919

sebge2emasphere opened this issue May 31, 2020 · 3 comments

Comments

@sebge2emasphere
Copy link

Expected Behaviour

The promise hasPermission must at some point answer something, but nothing happens.

Actual Behaviour

console.log('before permission');

try {
       this.push.hasPermission()
            .then((res: any) => {
                if (res.isEnabled) {
                    console.log('We have permission to send push notifications');
                } else {
                    console.log('We do not have permission to send push notifications');
                }
            })
            .catch(error => {
                console.error(error);
            })
            .finally(() => {
                console.log('has permission finally block');
            });
}
catch(e){
   console.log('error', e);
}

console.log('after permission');

This code works on Android, but on iOs the only output is 'before permission' and 'after permission'.

I also tried this (it works on Android):

        const pushObject: PushObject = this.push.init(options);

        pushObject.on('notification').subscribe((notification: any) => this.displayError('Received a notification', [JSON.stringify(notification)]));

        pushObject.on('registration').subscribe((registration: any) => this.displayError('Device registered', [JSON.stringify(registration)]));

        pushObject.on('error').subscribe(error => this.displayError('Error with Push plugin', [JSON.stringify(error)]));

In Xcode I see that the line: https://github.com/phonegap/phonegap-plugin-push/blob/master/src/ios/PushPlugin.m#L545 is invoked, but the if statement is false.

>>> Do you why this code if condition is false ?

if ([appDelegate respondsToSelector:@selector(checkUserHasRemoteNotificationsEnabledWithCompletionHandler:)]) {

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

iOs env:

iPhone 8, iOs 13.4.1 simulator
iPhone 8, iOs 13.3.1 real device
push notification enabled

Cordova CLI version and cordova platform version

Using ionic 5

npx cap doctor output:

💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 2.1.0
@capacitor/core: 2.1.0
@capacitor/android: 2.1.0
@capacitor/ios: 2.1.0
Installed Dependencies:
@capacitor/cli 1.4.0
@capacitor/core 1.4.0
@capacitor/ios 1.5.2
@capacitor/android 1.5.2

Plugin version

"phonegap-plugin-push": "^2.3.0",
@kapten96
Copy link

kapten96 commented Jun 3, 2020

having same problem

@Jiawei-Nick
Copy link

Jiawei-Nick commented Jul 7, 2020

I also tried using the previously initialized object "this.push" to do call hasPermission() also failed like you do.

I'm able to to do this by using this approach "PushNotification.hasPermission(callBackFunction)" and it success call and return the callback function as expected.

@TheMikewithaK
Copy link

Does anyone have a solution for this? I'm having the same problem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

4 participants