After days of trials and searching, I found the perfect solution! No need to install any plugins, no need to add complicated java script. I thought I’d share here:
-
go to your API connector.
-
Create a new API call specifically for a user, for example if your app has message function. see below screenshot:
{ "app_id" : "YOUR APP_ID", "data": {"foo": "bar"}, "contents" : {"en" : "<Body>"}, "include_player_ids" : ["<Player id>"], "url" : "<URL>", "headings" : {"en" : "<Title>"}, "ios_badgeType" : "<Badge type>", "ios_badgeCount" : "<Badge number>" }
-
be sure to put value under Player id (you can copy from your existing onesignal playerID, Badge type (increase) and Badge number (1). Then click Reinitialize Call.
-
do the same steps the author has mentioned above
adding javatobubble event →
add javascript:OneSignal.getUserId(function(id){bubble_fn_2(id)});
→
schedule your custon event which added the javatobubble event to your “current user” -
make a Push workflow, under the playerID, simply put the dynamic user’s playID you saved as user data
-
go to setting > SEO/metadatas, put
var OneSignal = window.OneSignal || []; OneSignal.push(function() { OneSignal.init({ appId: "YOUR APP_ID", subdomainName: "YOURDOMAINNAME.os.tc", notifyButton: { enable: true }, autoRegister: "true", autoPrompt: "true", httpPermissionRequest: { enable: true } }); });
-
go to Hosting files in your rout directory >
upload 3 files:
manifest.json; ( a file basically looks like this:
{ "gcm_sender_id": "YOUR FIREBASE SENDER ID", "gcm_sender_id_comment": "Do not change the GCM Sender ID" }
OneSignalSDKUpdaterWorker.js;
OneSignalSDKWorker.js
(the two js files can be found here: OneSignal Service Worker) -
You’re all set!
PS. I used a Free-Wrap to wrap my android app: GitHub - altventures/Free-Wrap at producthunt