# OneSignal Push Notification

## 1. Creating one signal app <a href="#creating-one-signal-app" id="creating-one-signal-app"></a>

Login or Signup in <https://onesignal.com/>​

1.After logging in click on **Add a new app.**

![](https://1319283601-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LF-v8mhdlBDzXsLDgdV%2F-LF2GLfAngdF4JFSJB3a%2F-LF2GR7J2qZ4et-MRmGE%2Fimage.png?alt=media\&token=8f2853b4-76a0-4e44-9940-122d8df0aa48)

2\. Then add  you app name and click create

![](https://1319283601-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LF-v8mhdlBDzXsLDgdV%2F-LF2GLfAngdF4JFSJB3a%2F-LF2GTcVMUh7Qgqt3ssT%2Fimage.png?alt=media\&token=9e454272-3395-403b-9bd2-72d6e19af3eb)

3\. After that select platform and hit next:&#x20;

{% hint style="info" %}
If you are building your app for android select Google Android  or select Apple iOS if you want to build your app for iOS.
{% endhint %}

![](https://1319283601-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LF-v8mhdlBDzXsLDgdV%2F-LF2GLfAngdF4JFSJB3a%2F-LF2GWCSEFEOEXorFrKQ%2Fimage.png?alt=media\&token=5651a58f-91b6-448e-bf8d-cb139d6b9b0f)

4\. After that you need to add Google Server API Key.

![](https://1319283601-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LF-v8mhdlBDzXsLDgdV%2F-LF2GLfAngdF4JFSJB3a%2F-LF2GYglAKRTKs7wb38o%2Fimage.png?alt=media\&token=c0908917-8cf5-4b53-a197-227bbd4654f3)

5\. To obtain Google Server API Key, Visit the [Firebase Console](https://firebase.google.com/) and sign in with your Google account.

![](https://lh3.googleusercontent.com/xRaibooh2XAx6wFLouVAfuPiAGWFHteVh9xBAvTM6Wav18iOBMl23yS2uOYCHu38Z6y20uGqmG5IjR3jBMtH64RjYE2ybgahfFe4IxuDCBnWlGt0zV2iK87U-wddb07zKTmJk7dM)

6\. Press "CREATE NEW PROJECT" or select an existing one below.

![](https://1319283601-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LF-v8mhdlBDzXsLDgdV%2F-LF2GLfAngdF4JFSJB3a%2F-LF2GeQnFpnTsukR6AN2%2Fimage.png?alt=media\&token=1bcd3470-d480-4ba7-a860-b7c7221e9d1d)

7\. Enter a project name and press "CREATE PROJECT".

![](https://lh3.googleusercontent.com/zh-l_dCTt0GC3DwbnUBhI-Rnx8vhWadjvwDWCTjeNN9O5_JEr42yXauWYnwmqb4qedciiJR8A38IwHwpKG588-StyUw-mpxVHnarjU8sbxVVXfX77Do-X4WCTidW5cT0RVKE9Sgu)

8\. Getting your Firebase Cloud Messaging token and Sender ID

![](https://lh3.googleusercontent.com/2UvW0r_m_mE0jdSEVQSGKOz9tOgK41vrWoW5wov5dwQ1nkbcGO60qhIPDiO_9_o4eTQggn1ESnzKzoO8mWN5pTKjjsHk-IwMl3r4BlhJ653VgjH0wbKSe58vtnBpjUptaO9UIR0a)

9\. Copy server key And sender Id And Add it in OneSignal app and click next

Select your target SDK **PhoneGap, Cordova, ionic** and hit next:

![](https://lh5.googleusercontent.com/5HtRbOeieZe8KHs0F1Z2PiDL4dQsc_UQhWBwAgC5UWH8yWa8jGFlYSe6IrugTYmYmayXNvX2sf5Liw2WnaTBCQLruZLAAB41sqwdmPboMK50-b62ViqXyR-yQYXvs8dDcTzpMfTb)

10\. After that Copy App ID

![](https://lh5.googleusercontent.com/-p_xIM5Kgw0CZlslqL9sOBAfY1OMvJCHDrlb2Scyg0U6-RIpt6jJ28CbHOc7l2hBDN34rVw1uZH7Uqfky9sQ9rzQKNo1Q0BVHOSNy_DJGmUYkGTWyMimoQI57PKOg-qsF0hlOdaw)

and add **App id And Sender id (googleProjectId)** in **src/providers/service/config.ts** file.

```typescript
oneSignalAppId: any = '28195d62-44f6-4934-a7f0-1551g200eb20';
googleProjectId: any = '575406234046';
```

{% hint style="info" %}
googleProjectId is Sender ID
{% endhint %}

11\. You need to build and run  your app on mobile at-least once to complete OneSignal registration . Then go back to OneSignal and click Check Subscribed User  and Done.

![](https://lh6.googleusercontent.com/91EW11Wlg_Hw7n-FA41x22PVwX9FNSWStvircge_CapIUrXAFujKbnlNs-yd7uv4zzp5SwJtIcDOVXnxmQ5eHcPRzNsSdCDgNplx8Gy8tDVOO0m4gmMcghfYv4NdTyyTO3MAsbnC)

## **Sending Push Notifications to your App** <a href="#sending-push-notification-from-wordpress" id="sending-push-notification-from-wordpress"></a>

For Sending Push Notifications, you need to  install OneSignal Push notification plugin and configure according to OneSignal official documents. <https://wordpress.org/plugins/onesignal-free-web-push-notifications/>

Add APP id and Rest API Key, which you have created before.

![](https://1319283601-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LF-v8mhdlBDzXsLDgdV%2F-LF2GLfAngdF4JFSJB3a%2F-LF2GyyNCMjdjFKg6r9O%2Fimage.png?alt=media\&token=e7f50c3c-ce41-4a1d-a1ae-b262b05363b7)

Go Push Notification menu and send notifications. You can send a notification to email id, pin code, city, state etc

![](https://lh6.googleusercontent.com/S-Qn6gd7gcDgWU_pupSbAme8hLlS8L1cZsSmCmuh7PIN8E1QZBFhiIW0zHgyyBIthfqC5rMswidv1VvSDEuac9FMeCIi6Lso8n4bJn0kr6ERe48RfHT5Qa_2CL8hChoiy78sPhy8)

You can send a notification when a new product is added in WooCommerce. One signal will automatically send notification on product publish

![](https://lh3.googleusercontent.com/V6JHZg7tAIdPqVgIXlcWmcfO4gdxvtUz24dxqYwskXi_q73QnL5ti2cfynCaMxamCwrjUEV4_6hM4w7KDxivkQBVX68SuL3wWHHvuBB-_0RaIHvk2OcFHfdo-nCfpLNhLiJfIalS)
