Problems with the Push Plugin (Error: Push plugin not found! See logs.)

I was trying to implement push (https://docs.ionic.io/services/push/). I am getting error. this is my repo https://github.com/eaktadiur/ionic-2-push-notification-Authenticating
this is my app.component

import { Component } from '@angular/core';
import {
  Push,
  PushToken
} from '@ionic/cloud-angular';
import { Platform } from 'ionic-angular';
import { StatusBar, Splashscreen } from 'ionic-native';
import { TabsPage } from '../pages/tabs/tabs';


@Component({
  template: `<ion-nav [root]="rootPage"></ion-nav>`
})
export class MyApp {
  rootPage = TabsPage;

  constructor(platform: Platform, public push: Push) {
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();
      Splashscreen.hide();
    });

    this.push.register().then((t: PushToken) => {
      return this.push.saveToken(t);
    }).then((t: PushToken) => {
      console.log('Token saved:', t.token);
    });

    this.push.rx.notification()
      .subscribe((msg) => {
        alert(msg.title + ': ' + msg.text);
      });


  }
}

image
I need some help to solve this problem. pls help me

1 Like

I have the same issue with the “plugin not found”, I’ve install the plugin via the CLI and it said “Plugin “phonegap-plugin-push” already installed on android.”, but when i run the app on device, it said “plugin not found”.

Hope you can foud the solution, and share it out with us. BTW, I use ionic1.

Thanks.

@eaktadiur you’re calling push plugin out side of the platform .ready callback.
Thats probably the root cause of your issue.

So I put the ionicPush in platform.ready, when I run my app in device, it still show me the “push plugin not found” error.

Here’s my code. Any idea?

$ionicPlatform.ready(function () {

  // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
  // for form inputs)
  if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
    cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    cordova.plugins.Keyboard.disableScroll(true);

  }
  if (window.StatusBar) {
    // org.apache.cordova.statusbar required
    StatusBar.styleDefault();
  }

  if ($window.geofence) {
    $window.geofence.initialize();
  }
  

  $ionicPush.register().then(function (t) {
    alert(t);
    console.log(t);
  }, function (error) {
    alert(error);
  });

});

@mhartington: I also try this. but same issue.

1 Like

Same issue, but using ionic1, hope you find the solution to work it out.

Did you solve this issue?

Same issues here on ionic v2… any help plz!

in the ionic 2 you should manually instantiate push object.
Example from documentation:
var push = Push.init({
android: {
senderID: ‘12345679’
},
ios: {
alert: ‘true’,
badge: true,
sound: ‘false’
},
windows: {}
});

Additional information you can find at the push plugin page https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/API.md

hi…
i have the same problem here.

anybody know how to solve this
:cry:

Hi,
From my understanding, the push plugin (from ionic-cloud) doesn’t work in the browser, that is expected.
The good news is that it should work nonetheless on a real device.

My solution for this problem was simply to activate the push code only on a real device (by testing the platform with the platform object).
I have a working sample project for ionic cloud push with ionic 2 at https://github.com/ajeans/ionic2-notification-push
Have a look at https://github.com/ajeans/ionic2-notification-push/blob/master/src/pages/home/home.ts.

1 Like

I was not satisfied with any of the answers here after I too ran into this problem, so here is how I solved it.

The problem occurs because I was attempting to view my app in the browser which doesn’t support push capabilities, since that can only work when running a device.

So I just needed to add an if statement that only runs the device-specific code when my code is running on an actual device.

In the constructor of the app.component.ts, we’re instantiating the Platform service and declaring it as the ‘platform’ variable. (see pic)

All we have to do is call one of Platform’s built-in methods to check on what platform we’re emulating our app on! This can be done easily by encasing our code in the following if statement ()

if (platform.is('cordova')) {
            // device only code
            this.push.register().then((t: PushToken) => {
                return this.push.saveToken(t);
            }).then((t: PushToken) => {
                console.log('Token saved:', t.token);
            });

            this.push.rx.notification()
            .subscribe((msg) => {
                console.log('Push Notification Received: ' + msg);
            });
        }

Platform documentation here: https://ionicframework.com/docs/v2/api/platform/Platform/

Hope this helps anybody.

2 Likes

Looks good, but I was wondering… Your code is doing a check to see if the platform is android. How would it be different if it were iOS ??

Hello @starkemc,
I don’t test for ios yet, my expectation is that you could simply check for “is not browser” rather “is android”.
Something like
if (!this.platform.is(‘browser’))
…

You may want to look at the possible platform values here: http://ionicframework.com/docs/v2/api/platform/Platform/

1 Like

i have the same problem here

anybody know how to solve this