Ionic Push: GCM project number not found in Android app

I am trying to use ionic.io to send push notifications. Here is what I did:

  • Create an application in GCM and enable the GCM API.

enter image description here

  1. Create credentials and get the api key.

enter image description here

  1. Create an application in the ionic.io toolbar
  2. Create a security profile and add an api key

enter image description here

  1. Create api token in ionic.io dashboard

enter image description here

  1. My source code in app.js which is generated by pushdemo ion triggering

     .run(function($ionicPlatform) { $ionicPlatform.ready(function() { var push = new Ionic.Push({ "debug": true }); push.register(function(token) { alert(token.token); console.log("Device token:",token.token); push.saveToken(token); }); 

7. Add plugin:

ion plugin adds phone button-plugin-push -variable SENDER_ID = "myproject_number"

I tried both with a quote and without it around myproject_number . This is the project number in step 1.

8. Set dev_push to false

9.Find my application in ionic.io via ionic io init

10.Run ion run android -lc

The following error message was found:

enter image description here

What about him? Can anyone help? Thanks.

+5
source share
3 answers

I had the same problem, usually because of the problem with the proxy server you are behind the proxy server, which means that you are using the Internet by sending a request to the server, so you must first use your own Internet (in this case if you use WIFI then it will work) secondly, after creating your project dirsctly make a login from your cinsole to ionic io it will send an email and password that will make your application in real time the third

 ionic plugin add phonegap-plugin-push --variable SENDER_ID="myproject_number" 

Use quotation marks to enter your project number. The project number is also called the GCM number, and your server key is the key that you created in the same project, it means the Google console, which allows you to use google services. and do not forget to add the Android platform.

+1
source

ion trigger pushCall ion login ion loading

// open the Google console 1-create a project 2-go google api 1-mobile APIs 2-select Google Cloud messaging and trick it 3- go to credentials and create an API key

// after that add the following plugin

ionic add-on ion-platform-web client ionic plug-in add phonegap-plugin-push -variable SENDER_ID = "991785317333" (do not remove quotes when adding gcm number)

// add platfom

ion platform add android ion io init ion config dev_push true

// open ion io go to setup 1-create api key
2-go to the certificate and create the name of the security profile profile, click on the android and add the GCM key and save it.

 //add this code to app.js angular.module('starter', ['ionic']) .run(function($ionicPlatform) { $ionicPlatform.ready(function() { var push = new Ionic.Push({ "debug": true }); push.register(function(token) { console.log("My Device token:",token.token); push.saveToken(token); // persist the token in the Ionic Platform }); }); }) 

// check if your mail is configured correctly with an open mail server open source // and then do the following:

 1-create collection give it a valid name 2-in body click on text and select Application/json it will add header automatically 3-add another header key as Authorization value as bearer followed by your api token from ionic io 4-select "raw " as the format of our json 2-in body section of your collection write following code { "tokens": ["DEV_DEVICE_TOKEN"], "profile": "PROFILE_NAME", "notification": { "message": "This is my demo push!" } } 

// now it will call a message in the browser

gcm_key ion configuration set
Ionic configuration dev_push false ion compilation android

install the application on your mobile and send a notification from the postman

(Mahesh Sampat Nigut) navi mumbai

+1
source

add this code to your app.js

 .run(function($ionicPlatform) { $ionicPlatform.ready(function() { var push = new Ionic.Push({ "debug": true }); push.register(function(token) { console.log("My Device token:",token.token); push.saveToken(token); // persist the token in the Ionic Platform }); }); }) 

and do not forget to run the command below

 ionic config set dev_push true 

when you test it in a browser, make cammand true, it means development mode, and when you make apk this time, you should make the false command above

0
source

All Articles