Push notifications are notifications that appear on your smartphone without opening the app. These types of messages allow fantastic interaction with customers and users of the app. Your app does not have to be open. This way, your customers do not miss any important news or messages. Push Notifications are suitable for many cases, e.g., for updates to orders, live tickers, or social media community. There must be an internet connection to allow app users to receive push messages. WebViewGold supports multiple ways of reaching your users via push notifications.
var seconds = 120; //seconds from now on
var message = "It is Happy Hour now! Check it out!"; //the message
var button = "Open App"; //the text of the button
window.location.href = "sendlocalpushmsg://push.send?s="+ seconds +"=msg!"+ message +"&!#"+ button +"";
It could be used for different situations (countdowns, happy hours (like in the example code), reminders, …).
To cancel all scheduled local push notifcations run:
window.location.href = "sendlocalpushmsg://push.send.cancel";
Option 2: Use OneSignal Remote Push Notifications
If you want to use OneSignal in your app, activate these options in Config.java (by switching the values from false to true):
Please set your OneSignal App ID in build.gradle file afterward:
Set up the OneSignal service for your Android app. Yay, you are done. You can send push notifications now:
If you want to use OneSignal URL Deeplinking (opens a specific URL when clicking on your notification), please add the desired URL with a custom field called url:
On the OneSignal.com Backend, you can fill in this key-value-pair window after clicking on “Advanced settings”. Using the OneSignal API, you can add the “url” field to the API request (https://documentation.onesignal.com/docs/onesignal-api).
Do you want to get each individual user ID on your server for further processing and individual user push messages? Just activate the PUSH_ENHANCDE_WEBVIEW_URL option in Confing.java (by switching the value from false to true) in order to append ?onesignal_push_id=XYZ to your WebView URL. If your WebView URL is https://www.example.org, WebViewGold will call https://www.example.org?onesignal_push_id=XYZ instead. Only your FIRST URL request will get that GET variable, so save it in a session or in a cookie to access it on your linked pages.
Option 3: Use Firebase Remote Push Notifications
1. Create a Firebase project
Before you can add Firebase to your WebViewGold app, you have to create a Firebase project in your Firebase Console.
2. Register your app with Firebase
After you created your Firebase project, you can add your WebViewGold app to it.
a. In the center of the Firebase console’s project overview page, click the Android icon to launch the setup workflow.
b. If you’ve already added an app to your Firebase project, click Add app to display the platform options.
Enter your app’s package name as changed/defined in this step.
Make sure that you enter the package name that your app is using. You cannot add or modify this value after you register your app with your Firebase project.
4. Click the Register app button.
5. Download google-services.json
Click Download google-services.json to obtain your Firebase Android config file (google-services.json) and replace the sample file already included in the WebViewGold project buy using the Mac Finder or the Windows Explorer:
6. Activate Firebase in WebViewGold
Go to Config.java file and turn the FIREBASE_PUSH_ENABLED variable to true.
7. That’s it!
Do you want to get each individual user ID on your server for further processing and individual user push messages? Just activate the FIREBASE_PUSH_ENHANCE_WEBVIEW_URL option in Confing.java (by switching the value from false to true) in order to append ?firebase_push_id=XYZ to your WebView URL. If your WebView URL is https://www.example.org, WebViewGold will call https://www.example.org?firebase_push_id=XYZ instead. Only your FIRST URL request will get that GET variable, so save it in a session or in a cookie to access it on your linked pages.
Option 4: Use bubble.io Push Notifications
1. Create a bubble.io app
2. Install the WebViewGold OneSignal Push plugin:
3. Follow the OneSignal instructions (see above) and the plugin instructions (see here and here).