Anyone succeed in getting onesignal to work?

Hello all, I tried to use onesignal, and downloaded their ionic project from github…

Than i did all the steps, and replaced the project id and the onesignal app id.
Than i built the project, and went to the onesignal dashboard, and tried to send a push notification, but it didn’t work. it said there are no users.
I checked and there werent any users indeed.

Did i miss any step in the setup? how am i supposed to register a user than? it isn’t written anywhere…
any help would be much appreciated.


Hello @shaulhadar,

Did you have add the plugin?
When you install the application the user will be added automatically.
It’s done on app.js file:

                                {googleProjectNumber: "703322744261"}, notificationOpenedCallback);

Hi @ingalb, thanks for your reply.

Here is what I have in the app.js:

// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// ‘starter’ is the name of this angular module example (also set in a attribute in index.html)
// the 2nd parameter is an array of 'requires’
angular.module(‘starter’, [‘ionic’])

.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Enable to debug issues.
// window.plugins.OneSignal.setLogLevel({logLevel: 4, visualLevel: 4});

var notificationOpenedCallback = function(jsonData) {
  alert("Notification received:\n" + JSON.stringify(jsonData));
  console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData));

// Update with your OneSignal AppId and googleProjectNumber before running.
                               {googleProjectNumber: "437854831774"},


I added the plugin and i can see it in the plugins folder…
i admit i didn’t see it in the config.xml…
also, I tried twice and it didn’t work…

after adding the plugin like this:

cordova plugin add com.onesignal.plugins.onesignal

is there any other step that’s needs to be done?

what’s weird is that i got a push message about a “hourly check” or something like this, i checked a gain and i still have no users in my app…


@shaulhadar Our system has a “Hourly Test Message” that is sent out to all users using the OneSignal example app id. I see you have "b2d3c0b6-5629-11e5-889f-e365857f7579" in the code you pasted. Please update this value to your OneSignal App Id found on our dashboard under “App Settings” under the “Keys & IDs” tab.

Let us know if that gets you up and running.


1 Like

Hi, thanks, I think i made i to work… but now i have some formatting issues…
I have some double brackets in the message, and it looks cramped… also it is not styled? i will check maybe i need to edit the options in the message area and it will be better.
anyways, thank you so much, and have a great day :slight_smile:

@shaulhadar Can you post a screenshot of the issue? Is the styling issue you’re seeing with the in app alert or the notification in the notification area or both?

The only time I seen odd styling issues with notifications is if android:targetSdkVersion is to low. It should be at least 16 but you should always uses the latest if you can.

Do you have another Android device to test your app on? Do you see the same issue there? If not feel free to send us your APK and we can help test.


@OneSignal Thanks for getting back to me.
I think i managed to make it work, i am still doing some testing,
I appreciate you getting back to me.
In case i will have a question i will let you know.
Thanks again,


Can you give me a example of how would i trigger a notification from user side and not from dashboard ?
i also wanted to confirm whether its free ?

Thanks !

Help is appreciated !

To trigger a notification from the client (the app)
You would use:

You can use $ to submit the data.

    method: "POST",
    url: ""
    data: {
        app_id: "<APPID>",
        contents: {"en": "English Message"}
    headers: {
        'Authorization': 'Basic <API_KEY>'

I would suggest against this due to security issues.

What you should so is create your own back-end to create the notifications, and store your api_key and app_id in there so that there is no chance that someone can find the data in your apk.
You can then use the app to make requests against your back-end to create the notifications, make sure to log the requests in-case someone uses it maliciously, that way you can block requests from that user/ip.

Thanks @EffakT !

I am aware of this security issue !

Thats why what i planned was :- (My backend is drpual)

  1. A new user will be registered for the notification only when he logs in.

  2. Once he is logged in , further any requests made to drupal are authenticated requests .no user can access that api unless and untill he is a authenticated user !

    so i plan to store my all sensitive data like user/auth keys for onesignal in drupal’s backend.

  3. From here i can do two things ;:-
    a. Only after login make authenticated request to drupal and ask for secrect keys and store it somewhere in the app say localstorage. from here every time the notification is to be sent the key from localstorage would be sent .

    here everytime i will make sure to reset that localstorage after every logout !


    b. if storing the keys is not secured then every time i want to send notification i will have have to make one additional http call before to get that key. which will not be stored anywhere. this http calls take few seconds to process so it will not be a issue.

what you think about this approach ? any pitfalls ? thank you again for your response :grinning:

I would say that would work fine, except never store the sensitive data (secret keys or user/auth keys) on the device itself.

thanks your answer and linked helped me ! :slightly_smiling:

You could use the device id as a key, then store the device id in the back-end and on first auth, do some checks to make sure it is valid/correct and then activate the device id for access.
The only issue is that I believe IOS gives a new device id every time the app is reinstalled, so the app would have to re-auth, and you would end with heaps of devices if it happens too often (you could store a last-used date and remove the device authorization after however long.

For better security of the back-end, make it harder to spoof the device id.
Send the UUID and a Hash. The hash can be the UUID appended with a secret key stored in the app (maybe generate it on first run or something), appended along with a timestamp, all encoded in sha1 or sha256. e.g
Its not 100% foolproof, but it would help reduce the risk of the UUID being spoofed.

nice idea ! but the heaping of devices would also be applicable for android ! even if devices give same device id back , users tend to login from multiple android devices which they keep switching or some might use the app in their device + in a virtual machine like bluestacks !

Try ng-drupal-7-services. Its an awesome module to work with Drupal Services

Hey there @EffakT,
Can you please help me here a bit. I am very new to all this and I just want to check if I can send a notification from user side. Can you pls pls pls give me the entire code including the service I should make and the server etc. to use the above code you mentioned.

@OneSignal I have been trying to configure OneSignal notifications for my app. The problem is I cannot find a way to configure it such that the sender doesn’t get the notification I just sent. Also I want to make groups or segments of users dynamically according to the tags I added but I am unable to figure that out either. Can segments be made programmatically? Or we have to use the dashboard and do it manually.

Each person registered on your app has a unique id. So lets say you have four users with ids 1,2,3,4 and 2 wants to send a message to 4. Your onesignal code will look something like

var notificationObj = {
contents: {en: “Hello from user with id 2”},
include_player_ids: [4], //This is the OneSignal ID of the person. Dont forget that IDs are sent in an array
headers: {
“Content-Type”: “application/json”,
“Authorization”: “Basic NGEwMGZmMjItY2NkNy0xMWUzLTk5ZDUtMDAwYzI5NDBlNjJj”

$“”, notificationObj);

Your next question might be “so how do I get to know each users signal ID”? Sigh, I would advice you read the docs. But most times we are too agitated to take time and only relax after wasting more time so…

Within your app try and grab the devices assigned OneSignal ID

window.plugins.OneSignal.getIds(function(ids) {
//ids is the devices OneSignal ID
//Now store this somewhere so that you can reference this ID based on the unique userid of the person

Now whenever you need to send a message to this particular person, all you need to do is call up the saved OneSignal ID and send it to OneSignals servers to send it to the device.

I really hope this covers is.

1 Like

Thank you, thank you, thank you soo much. I am starting to love this platform.
It’s quite understandable, I’ll try it and let you know!!
Thanks once again! :heart_eyes:

hi EffakT, That code helped me a lot in so many hours of researching I’ve added it: included_segments: [“All”] because I need the message to reach everyone but when I do that, I get a popup with the push I sent there is some way Send everyone but me?

Something like exclude_segmens: me

: D

Thank you !