# Ionic Push: Send PUSH to all users using API

**URL:** <https://forum.ionicframework.com/t/ionic-push-send-push-to-all-users-using-api/60254>\
**Category:** ionic-v1\
**Created:** [August 11, 2016, 12:14pm UTC](https://forum.ionicframework.com/t/ionic-push-send-push-to-all-users-using-api/60254 "2016-08-11T12:14:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dyrk](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/dyrk/32/102345_2.png) [@Dyrk](https://forum.ionicframework.com/u/Dyrk)\
**Post date:** [August 11, 2016, 12:14pm UTC](https://forum.ionicframework.com/t/ionic-push-send-push-to-all-users-using-api/60254/1 "2016-08-11T12:14:36Z")

</div>

I see in the control panel possibility to send push notification to all users. Is it possible to do the same using API? I tried already to send a request with empty tokens array `"tokens": []` however, no notifications were delivered.

If it’s not yet possible to do through the API, can you suggest me the best practice how to store these tokens on backend side in DB? I see that app generates token each time on startup, and I don’t have and don’t want to have registration. So, basically, if user will kill and re-open app 100 times I will save 100 different tokens for his device.  
How can I understand that some tokens are already outdated and should be removed from DB?

So far I used the standard code to register device in ionic platform:

```auto
    var push = new Ionic.Push({
      "debug": true,
      "pluginConfig": {
        "ios": {
          badge: "false",
          sound: "true"
        }
      },
      "onNotification": function(notification) {
        var payload = notification.payload;
        console.log(notification, payload);
      },
      "onError": function(err) {
        console.log(JSON.stringify(err));
      }
    });

    push.register(function(token) {
      console.log("Device token:",token.token);
      push.saveToken(token); // persist the token in the Ionic Platform
    });

```

---

<div class="post-metadata">

**Author:** ![Dyrk](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/dyrk/32/102345_2.png) [@Dyrk](https://forum.ionicframework.com/u/Dyrk)\
**Post date:** [August 12, 2016, 12:25pm UTC](https://forum.ionicframework.com/t/ionic-push-send-push-to-all-users-using-api/60254/2 "2016-08-12T12:25:55Z")

</div>

Still didn’t find a solution without registration. So far had to implement simple subscription with email + hidden deviceToken and save it in DB with `Devices.findOrCreate(where: { email: email}, defaults : {device_token : token})` on backend side. In this case, 1 mobile device has only one unique token. However, those who didn’t subscribe to push notifications with their email will never receive them.

---

<div class="post-metadata">

**Author:** ![Dyrk](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/dyrk/32/102345_2.png) [@Dyrk](https://forum.ionicframework.com/u/Dyrk)\
**Post date:** [August 12, 2016, 2:44pm UTC](https://forum.ionicframework.com/t/ionic-push-send-push-to-all-users-using-api/60254/3 "2016-08-12T14:44:06Z")

</div>

Is it possible to see the list of all devices which were registered with `push.saveToken(token);` in the Ionic Dashboard?

---

<div class="post-metadata">

**Author:** ![temitope](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/temitope/32/102438_2.png) [@temitope](https://forum.ionicframework.com/u/temitope)\
**Post date:** [August 16, 2016, 6:02am UTC](https://forum.ionicframework.com/t/ionic-push-send-push-to-all-users-using-api/60254/4 "2016-08-16T06:02:47Z")

</div>

this was annoying for me too but found it here-

```
{
  "tokens": [""],
  "send_to_all": true,
  "profile":"profile_name_goes_here",
  "notification":{
    "message": "ionicpush send to all."
  }
}
```

---

<div class="post-metadata">

**Author:** ![Dyrk](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/dyrk/32/102345_2.png) [@Dyrk](https://forum.ionicframework.com/u/Dyrk)\
**Post date:** [August 16, 2016, 7:23am UTC](https://forum.ionicframework.com/t/ionic-push-send-push-to-all-users-using-api/60254/5 "2016-08-16T07:23:09Z")

</div>

Thank you, @temitope! I have no idea why I didn’t find it anywhere in docs…

---

<div class="post-metadata">

**Author:** ![nitinw631](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@nitinw631](https://forum.ionicframework.com/u/nitinw631)\
**Post date:** [April 10, 2017, 12:05pm UTC](https://forum.ionicframework.com/t/ionic-push-send-push-to-all-users-using-api/60254/6 "2017-04-10T12:05:39Z")

</div>

i been looking for this “send\_to\_all” variable for past 8 hour… thanks @temitope. you made my day

---

<div class="post-metadata">

**Author:** ![wanwancs](https://avatars.discourse-cdn.com/v4/letter/w/22d042/32.png) [@wanwancs](https://forum.ionicframework.com/u/wanwancs)\
**Post date:** [April 16, 2017, 7:17am UTC](https://forum.ionicframework.com/t/ionic-push-send-push-to-all-users-using-api/60254/7 "2017-04-16T07:17:06Z")

</div>

Thank you temitope  
…
