Build push notifications into an Ionic 1.x app
Your app should be available at ionic.io. Theoretically you can view your apps with Ionic View, a mobile app. I’m running android 4.1.2 and it no workey.
Add a plugin for connecting to the internet with android:
With my testing my other ionic apps missing this plugin was driving me crazy this blog post helped me out. The author has a lot of good tutorials.
Paste in this code to
app_id comes from https://apps.ionic.io/apps and look your at your app’s id.
api_key comes from your apps page > Settings > Keys > Public Key.
This will build your android application. I email this file:
ionic-push-starter/platforms/android/build/outputs/apk/android-debug.apk to myself and download my app on my phone.
.apk is the filetype of your android app. Ionic converts your html, css and js into native code.
Email the above file to yourself. You may have to disable some security settings on your android phone.
Are the ways to test in the emulator and browser. We don’t have push notification functionality there. To use the android emulator you must have the android sdk installed. Push notifications must be tested on a physical device. Open the app, go to the push tab, you’ll see Ionic’s note on that.
This is all pretty much from the docs.
Click “Create Project” on google developer console.
Copy in the top bar your Project ID and Project Number. The Project Number will later become your GCM sender ID.
Turn on Google Cloud Messaging for Android under Mobile APIs.
Then click “Enable API”. It is taking a bit of time for me
Then create API Public Access Key. Click Create new Key.
From the ionic docs
In the Create a new key dialog, click Server key.
In the resulting configuration dialog leave the box blank to allow connections from any IP
Save the API Key that was generated.
Send the google key to the ionic push service. They will be taking care of this for us.
www/js/app.js go into the
.config block we copied in earlier. Uncomment the
gcm_id property and add the Project Number that’s on the homepage of your google app (click Overview).
Add the plugin:
Now email the app to yourself, download it on your phone. Click register and an alert box with the token will appear