Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ionic-native 5] push plugin registration not called #2253

Closed
peterpeterparker opened this issue Jan 6, 2018 · 12 comments
Closed

[ionic-native 5] push plugin registration not called #2253

peterpeterparker opened this issue Jan 6, 2018 · 12 comments

Comments

@peterpeterparker
Copy link
Contributor

I'm submitting a ... (check one with "x")
[X] bug report

Current behavior:
With ionic-native 5, the push plugin registration isn't called and therefore push notifications doesn't work / no push messages are received

Steps to reproduce:

See code

Related code:

 import {Injectable} from '@angular/core';
 import {Push, PushObject, RegistrationEventResponse} from '@ionic-native/push';
 
@Injectable()
export class PushNotificationService {
   ...
    init():Promise<{}> {
    return new Promise((resolve) => {
        this.pushObject = this.push.init({
            android: {
                senderID: 1234
                icon: 'icon_notification',
                iconColor: '#000000',
                sound: true
            },
            ios: {
                alert: 'true',
                badge: true,
                sound: 'true',
                clearBadge: true
            },
            windows: {}
        });

       this.pushObject.on('registration').subscribe((data: RegistrationEventResponse) => {
            this.clearTheBadge().then(() => {
                // Do nothing
                 }, () => {
                 // Do nothing
            });
             }
 
             resolve();
         });
     }

Test:

I tested this behavior on both real iPhone (iOS 11) and Samsung Edge (Android 6).

I could also confirm that my environment and notifications are fully working/correctly handled/received while using ionic-native 4.5.2

Other information:

"ionic-native/core": "^5.0.0-beta.4"
"ionic-native/push": "^5.0.0-beta.4"

cli packages:

@ionic/cli-utils  : 1.19.0
ionic (Ionic CLI) : 3.19.0

global packages:

cordova (Cordova CLI) : 8.0.0 
Gulp CLI              : CLI version 3.9.1 Local version 3.9.1

local packages:

@ionic/app-scripts : 3.1.7
Cordova Platforms  : android 6.4.0 ios 4.5.4
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 26.1.1
ios-deploy        : 1.9.2 
ios-sim           : 5.0.13 
Node              : v9.3.0
npm               : 5.6.0 
OS                : macOS Sierra
Xcode             : Xcode 9.2 Build version 9C40b 

Environment Variables:

ANDROID_HOME : /Users/xxxxx/Library/Android/sdk

Misc:

backend : pro

Log:

What I could find in the console when I pair my iPhone with Xcode when I use ionic-native 4.5.2 respectively what I don't notice at all while using ionic-native 5

2018-01-06 12:53:44.477478+0100 MyApp[464:43451] Push Plugin register called
2018-01-06 12:53:49.771505+0100 MyApp[464:43364] Push Plugin register success: <64a3...

@peterpeterparker peterpeterparker changed the title [ionic-native 5] push plugin registration not called / push doesn't work [ionic-native 5] push plugin registration not called Jan 6, 2018
@jzwcars
Copy link

jzwcars commented Jan 9, 2018

I am facing (almost) the issue here. It seems however not related to the Ionic/Native version but related to the Xcode version. It will work when compiled on a machine with Xcode 8, however will not work at all when compiled with Xcode 9.

The on('registration') event is never called. No error whatsoever is available.

Both machines have an identical Cordova / Ionic installation:

package.json

"dependencies": {
    [...]
    "@ionic-native/core": "4.5.2",
    "@ionic-native/in-app-browser": "4.5.2",
    "@ionic-native/network": "4.5.2",
    "@ionic-native/push": "4.5.2",
    "@ionic-native/splash-screen": "4.5.2",
    "@ionic-native/status-bar": "4.5.2",
    "@ionic/storage": "2.1.3",
    [...]
}

cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.19.0
ionic (Ionic CLI) : 3.19.0

global packages:

cordova (Cordova CLI) : 7.1.0 

local packages:

@ionic/app-scripts : 3.1.7
Cordova Platforms  : android 6.2.3 ios 4.5.4
Ionic Framework    : ionic-angular 3.9.2

Machine A (Xcode 8 - Working):

System:

ios-deploy : 1.9.2 
ios-sim    : 6.0.0 
Node       : v6.11.4
npm        : 5.5.1 
OS         : OS X El Capitan
Xcode      : Xcode 8.2.1 Build version 8C1002

Machine B (Xcode 9 - NOT working):

System:

ios-deploy : 1.9.2 
ios-sim    : 6.1.1 
Node       : v8.9.0
npm        : 5.6.0 
OS         : macOS High Sierra
Xcode      : Xcode 9.2 Build version 9C40b

@peterpeterparker
Copy link
Contributor Author

@jzwcars in case not related to ionic-native plz open an other issue/delete your post in the plugin itself (https://github.com/phonegap/phonegap-plugin-push/issues).

the issue I reported is strictly related to the test of ionic-native 5 beta

@jzwcars
Copy link

jzwcars commented Jan 9, 2018

@peterpeterparker the error itself and also the process to reproduce are 100% identical with your issue. If this bug is related to ionic-native it may have been present in version 4.5.2 already.

@peterpeterparker
Copy link
Contributor Author

@jzwcars not at all. read my issue, with 4.5.2 it works like a charm.
plz report your problem elsewhere, like in ionic forum for example.

@ihadeed ihadeed self-assigned this Jan 9, 2018
@ihadeed ihadeed added this to the 5.0.0 milestone Jan 9, 2018
@ihadeed ihadeed added the bug label Jan 9, 2018
@etchen99
Copy link

etchen99 commented Mar 9, 2018

Registration does not work for me consistently on 4.5.3. I added some debugging messages and I believe there is a race condition - the event handlers are not always added before the registration is completed and emitted.

@glebmachine
Copy link

I have the same, i can't initiate push and unable to subscribe to notifications on start.
Only on user interactions (5.0.0.beta-14)

@peterpeterparker
Copy link
Contributor Author

I could confirm, tested on both real devices iPhone 6s/iOS 11.4 and Samsung Edge/Android 7, that push notifications works fine with ionic-native v5.0.0-beta.14

Back in January, I reported that the registration wasn't called, I could confirm that now this is solved (see below logs for proofs)

I have opened this issue in January and therefore I gonna close it

Thx team for the great work 👍

2018-08-15 12:25:51.419630+0200 Fluster[344:77637] PushPlugin.register: clear badge is set to 1
2018-08-15 12:25:51.419676+0200 Fluster[344:77637] PushPlugin.register: better button setup
2018-08-15 12:25:51.419787+0200 Fluster[344:77637] FCM Sender ID (null)
2018-08-15 12:25:51.419803+0200 Fluster[344:77637] Using APNS Notification
2018-08-15 12:25:51.427911+0200 Fluster[344:77526] Push Plugin register success: <1c0fc1bd ... 04e9bc90 0fde2740>

@glebmachine
Copy link

glebmachine commented Aug 15, 2018

@peterpeterparker could you please share your code?
I still facing this issue and struggling(

P.S. Also, please share your package.json ionic deps

@peterpeterparker
Copy link
Contributor Author

@glebmachine same code as above, I didn't change a single line of code

@peterpeterparker
Copy link
Contributor Author

about package.json, all ionic-native in version v5.0.0-beta.14
phonegap-plugin-push 2.2.3

@glebmachine
Copy link

Thank you, will check twice and come back)

@toriqo
Copy link

toriqo commented Jun 11, 2020

from the messed up docs here you can clearly see the racing condition (first the PushObject is initialized THEN the event listeners are added) thus missing out on the reigstration event.

yesterday it ran just fine, today it's not being fired at all. didn't change a thing in the code.

will this be fixed?

P.S.
And to support my theory, here are the logs from xcode, showing the registration and from Safari inspecting the ionic app. the latter should've displayed the console.log with the registration token, just like xcode did.

Screenshot 2020-06-11 at 13 11 01

Screenshot 2020-06-11 at 13 10 46

P.P.S
and when it works, it's triggered twice

Screenshot 2020-06-11 at 17 04 22

Screenshot 2020-06-11 at 17 03 46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants