Really Easy Unique Push Notifications with OneSignal and WebViewGold for iOS and Android

For anyone looking to integrate unique push notifications like for a chat app and you need to grab the unique ID of each person so they can chat with each other don’t waste a day in pain like I did. Here was my super easy solution in the end.

Assumptions:
It is assumed you are attempting to make a mobile app with the intention of wrapping it in a wrapper in order to get native functions. YOU CAN NOT SEND PUSH NOTIFICATIONS FROM MOBILE SAFARI ON IOS.

Solution for iOS (Must have a Mac for Xcode and an iPhone to test push):

  1. Set up an account with OneSignal https://onesignal.com/

  2. Purchase a Developer Account from Apple for XCode $100

  3. Purchase WebViewGold from here ($70 but way worth it over SuperView): https://www.webviewgold.com/

  4. Configure WebViewGold with Xcode (may be a pain but follow WebViewGold’s documentation and set up all of your certificates so you can view your app on your mobile device).

  5. Configure OneSignal in your WebViewGold project file on Xcode (again follow their documentation to the letter). You will also need to go through the painful process of connecting OneSignal and your Apple Developer account. (Importing the iOS push certificate.) Documentation is on OneSignal’s website and can be found here. https://documentation.onesignal.com/docs/generate-an-ios-push-certificate

  6. Make sure in WebViewGold you enable the kPushEnhanceUrl option in the Constant.swift file

  7. Make sure when you launch your app (must be on a real iPhone) it prompts you to allow push notifications.

  8. Back on Bubble install the free OneSignal Push Notifications plugin by Two Bits (thanks again for this by the way) https://bubble.io/plugin/onesignal-push-notifications-1513549695528x981969459703709700

  9. Fill in your app id and rest API key fields from OneSignal in the One Signal Push Notifications plugin api key fields. (MAKE SURE YOU ADD (Basic ) yes capital B and yes space before your rest API key fields only. You can watch a video of this here https://www.youtube.com/watch?v=E1-iXBiZuFU

  10. Here is the magic of Webview gold. (Again make sure you did step 6.) WebViewGold adds the player id ( playerID ) from Onesignal to the URL of the FIRST PAGE of your bubble site when it is launched. You can then grab the id by using get the “get data from page URL” option in bubble. I would do this on page load of that first page. Then you specify a key with the name onesignal_push_id and you can store that value in your database for your user.

  11. Using that unique ID you call the custom OneSignal Push Workflow as need and fill in the unique ID from your database.

Hope this helps!

5 Likes