Push plugin issue


#1

Hello,

I want implement push notification in our APP. Followed all the steps from

But I am facing an issue of Push plugin not installed. Following are the list of errors:

Native: tried calling Push.hasPermission, but the Push plugin is not installed.
pluginWarn

Install the Push plugin: 'ionic cordova plugin add phonegap-plugin-push’
pluginWarn

Native: tried calling PushNotification.init, but the PushNotification plugin is not installed.

Please do help urgently.

Thanks,
Raj


#2

Try calling it after platform is ready

this.platform.ready().then(() => {
// plugin initialization and stuff goes here
})

Of course, make sure you import Platform from ionic-angular.

Good luck.


#3

@obinnae Thanks for your reply. I tried as above but still no success. Following is the code of the same:


platform.ready().then(() => {
        this.push.hasPermission().then((res: any) => {
            alert(res.isEnabled);
            if (res.isEnabled) {
            console.log('We have permission to send push notifications');
            } else {
            console.log('We don\'t have permission to send push notifications');
            }
        });
        const options: PushOptions = {
            android: {
            senderID: 'XXXXXXX'}, //added actual id in my app
            ios: {
            alert: 'true',
            badge: true,
            sound: 'false'
            },
            windows: {},
            browser: {
                pushServiceURL: 'http://push.api.phonegap.com/v1/push'
            }
        };
        const pushObject: PushObject = this.push.init(options);

        pushObject.on('notification').subscribe((notification: any) => console.log('Received a notification', notification));

        pushObject.on('registration').subscribe((registration: any) => alert(registration.registrationId));

        pushObject.on('error').subscribe(error => console.error('Error with Push plugin', error));
      
    });

Please let me know what I am missing.

Thanks,
Raj


#4

Please edit your post, it is not very readable at the moment.
Use the </> button above the input field to format your code, command line output or error message (select the text first, then click the button or wrap it in ``` manually). Check the preview if it looks better. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.


#5

Hey RajeshAdam9999,
please did you fixe your issue !!? i have the same one!