The WonderPush Developer Hub

Welcome to the WonderPush developer hub. You'll find comprehensive guides and documentation to help you start working with WonderPush as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Ionic Push Notifications

How to set up WonderPush push notifications on Ionic cross-platform apps

Get push notifications working with Ionic in minutes

Setting up push notifications for your Ionic app is easy. Push notifications are the ideal solution to re-engage users and bring them back to your app.

Estimated setup time: 5 minutes.

Prerequisites

You'll need:

  • NodeJS
  • Ionic v4+ using Angular (React is not supported)
  • Cordova v9 (Capacitor is not supported)
  • For Android:
    • A device or emulator with Google Play services installed and up-to-date
    • A Firebase account
    • An application with minSdkVersion >= 21
  • For iOS:
    • XCode
    • An iOS device such as an iPhone or an iPad
    • An iOS Push Certificate (here's a how to obtain it)

If you haven't already, sign up for a free account on wonderpush.com.

Step 1. Create your project

Click on New Project:

Choose a name for your project and select Android and iOS as platforms then click Create:

📘

Already have a project?

Just add the Android or iOS platforms to any existing project by going to Settings, selecting the first tab named after your project and clicking Edit. You'll be presented a form that lets you add a platform.

Step 2. Setup your push credentials

Android - Add your Firebase credentials

  1. Locate your Server Key and Sender ID in the Firebase project Cloud Messaging settings.

In your Firebase project console, click the gear icon (⚙️) and select Project settings and go to the Cloud Messaging tab.

  1. Go to your WonderPush dashboard, in the Settings page, select the Platforms tab and click on Android application.
  1. Paste the Server key.
  2. Click Save.

iOS - Upload your push certificate

Head to the Apple developer website, go to Accounts, then Certificates, Identifiers & Profiles and click the plus button to add a new certificate. Choose the type Apple Push Notification service SSL (Sandbox & Production):

Then select your app ID (be sure not to select the app ID for the notification service extension):

Follow the rest of the wizard to obtain your certificate.

Go to Settings / Platforms, click the iOS application section title and fill in:

  • your push certificate by clicking the Browse button,
  • the push certificate password if appropriate.

📘

Be sure to check how to use WonderPush in both Sandbox & Production.

Step 3. Add the SDK

Create your cordova application if you haven't already, see the official Cordova guide for more details.

Take note of your Client ID and Client Secret from the Platforms tab of the Settings page:

ionic cordova plugin add wonderpush-cordova-sdk --variable CLIENT_ID=YOUR_CLIENT_ID --variable CLIENT_SECRET=YOUR_CLIENT_SECRET
ionic cordova plugin add wonderpush-cordova-sdk-fcm --variable SENDER_ID=YOUR_SENDER_ID
npm install @ionic-native/wonderpush

Replace YOUR_CLIENT_ID and YOUR_CLIENT_SECRET with the appropriate values you find in the Platforms tab of the Settings page, in the Android application or iOS application section.
Replace YOUR_SENDER_ID with the Firebase Sender ID from step 2

🚧

iOS apps: Do you already have your Notification Service Extension?

Look for a message in your output that warns you that the Notification Service Extension could not have been added automatically.
Look at our Adding a Notification Service Extension guide for the manual steps required.
If you do not follow these steps, you won't be able to use iOS 10 rich notifications, but everything else would work normally.

📘

Upgrading to the latest version of the SDK

First, take note of the variables you used by reading the cordova.plugins.wonderpush-cordova-sdk object in your package.json. If you forgot this step, your version control will help you.

Run this command:

ionic cordova plugin rm wonderpush-cordova-sdk --variable CLIENT_ID= --variable CLIENT_SECRET=

And follow these instructions at the top of this step to re-add it.

Step 4. Add required code

Let's add the code that will prompt users to subscribe to push notifications. We recommend you place this code in a more suitable moment in the user journey, but we'll do it at launch time for now.

In your src/app/app.module.ts file, add the lines preceded by the + marker:

import { AppComponent } from './app.component';
 import { AppRoutingModule } from './app-routing.module';
+import { WonderPush } from '@ionic-native/wonderpush/ngx';
 
 @NgModule({
   declarations: [AppComponent],
@@ -16,6 +17,7 @@ import { AppRoutingModule } from './app-routing.module';
   providers: [
     StatusBar,
     SplashScreen,
+    WonderPush,
     { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
   ],
   bootstrap: [AppComponent]

In your src/app/app.component.ts file, add the lines preceded by the Add this line: comment:

import { Component } from '@angular/core';
 import { Platform } from '@ionic/angular';
 import { SplashScreen } from '@ionic-native/splash-screen/ngx';
 import { StatusBar } from '@ionic-native/status-bar/ngx';
+import { WonderPush } from '@ionic-native/wonderpush/ngx';
 
 @Component({
   selector: 'app-root',
@@ -13,6 +15,7 @@ export class AppComponent {
   constructor(
     private platform: Platform,
     private splashScreen: SplashScreen,
+    private wonderPush: WonderPush,
     private statusBar: StatusBar
   ) {
     this.initializeApp();
@@ -22,6 +25,7 @@ export class AppComponent {
     this.platform.ready().then(() => {
       this.statusBar.styleDefault();
       this.splashScreen.hide();
+      this.wonderPush.subscribeToNotifications();
     });
   }
 }

Finally, open your config.xml file and add the following line:

<preference name="SplashScreen" value="screen" />
     <preference name="SplashScreenDelay" value="3000" />
     <platform name="android">
+        <preference name="android-minSdkVersion" value="21" />
         <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
             <application android:networkSecurityConfig="@xml/network_security_config" />
         </edit-config>

Android: adopt AndroidX

Starting v3.0+, WonderPush uses, and requires you to use Android X. If your app is already using AndroidX, just skip to the congratulations below: you're done!

Otherwise, read on: it's an easy migration. In a shell, type:

ionic cordova plugin add cordova-plugin-androidx
ionic cordova plugin add cordova-plugin-androidx-adapter

Receive your first push!

Build & run your application and get the permission prompt you've configured:

Wait a couple of minutes and receive the default welcome notification:

👍

Congratulations, you're done!

Updated 3 days ago

Ionic Push Notifications


How to set up WonderPush push notifications on Ionic cross-platform apps

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.