# How to send push notifications with my app

**URL:** <https://community.homey.app/t/how-to-send-push-notifications-with-my-app/86397>\
**Category:** Developers\
**Created:** [August 7, 2023, 11:21am UTC](https://community.homey.app/t/how-to-send-push-notifications-with-my-app/86397 "2023-08-07T11:21:57Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maven](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/maven/32/110403_2.png) [@Maven](https://community.homey.app/u/Maven)\
**Post date:** [August 7, 2023, 11:21am UTC](https://community.homey.app/t/how-to-send-push-notifications-with-my-app/86397/1 "2023-08-07T11:21:57Z")

</div>

To send push notifications with my homey app am I implementing it correctly using the web api?

I currently get a “Missing Scopes” error when trying to send a push notification but I don’ believe i’m missing anything having “homey:manager:api” already.

sendPushNotification(users: User, message: string) {

```
  const apiToken = await this.homey.api.getOwnerApiToken();

  for (const user of users) {
      this.log(user);
      try {
          
          const response = await this.homeyApi.flow.runFlowCardAction({
              uri: 'homey:manager:mobile',
              id: 'homey:manager:mobile:push_text',
              headers: {
                  'Authorization': `Bearer ${apiToken}`
              },
              args: {
                  user: {
                      athomId: user.id,
                      id: user.id
                  },
                  text: message
              },
          });
          ......

```

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [August 7, 2023, 4:00pm UTC](https://community.homey.app/t/how-to-send-push-notifications-with-my-app/86397/2 "2023-08-07T16:00:11Z")

</div>

Maybe this Homey script gets you going

> [@Sending notification will not work in Homeyscript](https://community.homey.app/t/sending-notification-will-not-work-in-homeyscript/79235/8):
>
> On HomeyPro early 2023 version 10.0.0-rc.122, I found it necessary to give both “athomID” and “id” parameters for a successful push\_text. Example code: // Tested using versions: // - Homey Pro (Early 2023), version 10.0.0-rc.122 // - Homey Web App version 1.9.58 // Status as of 15-July-2023: working // send message to specified user, or if none specified, then first user in getUsers list var user\_name = (typeof args[0] === 'string') ? args[0] : ''; var user\_athom\_id = null; var user\_id …

---

<div class="post-metadata">

**Author:** ![Maven](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/maven/32/110403_2.png) [@Maven](https://community.homey.app/u/Maven)\
**Post date:** [August 7, 2023, 4:12pm UTC](https://community.homey.app/t/how-to-send-push-notifications-with-my-app/86397/3 "2023-08-07T16:12:32Z")

</div>

Thank you @Peter_Kawa. Though i have a working homeyscript, i will double check the post. I suspect though that my issue is more SDK related.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [August 7, 2023, 4:26pm UTC](https://community.homey.app/t/how-to-send-push-notifications-with-my-app/86397/4 "2023-08-07T16:26:25Z")

</div>

The correct way of using the Web API in an app is by using `homey-api`:

```auto
const { HomeyAPI } = require('homey-api');
...
const api = await HomeyAPI.createAppAPI({ homey: this.homey });
...
await api.flow.runFlowCardAction(...);

```

Although I’m not sure if this will solve your problem regarding missing scopes.

Documentation here: [HomeyAPI - Homey Web API](https://athombv.github.io/node-homey-api/HomeyAPI.html#.createAppAPI)

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [August 8, 2023, 5:21am UTC](https://community.homey.app/t/how-to-send-push-notifications-with-my-app/86397/5 "2023-08-08T05:21:19Z")

</div>

You can create a timeline notication from your app and the user can decide in timeline settings if he want to get an additional push message.

> **[ManagerNotifications - Homey Apps SDK v3](https://apps-sdk-v3.developer.homey.app/ManagerNotifications.html)**

---

<div class="post-metadata">

**Author:** ![Maven](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/maven/32/110403_2.png) [@Maven](https://community.homey.app/u/Maven)\
**Post date:** [August 8, 2023, 11:42am UTC](https://community.homey.app/t/how-to-send-push-notifications-with-my-app/86397/6 "2023-08-08T11:42:19Z")

</div>

Thank you for pointing this out @RonnyW, it’s easy to forget this option also exists. In my case however, this would kind of defeat the purpose of the app, so I’m still banging my head against the wall trying to solve the scopes issue. 😄

---

<div class="post-metadata">

**Author:** ![Maven](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/maven/32/110403_2.png) [@Maven](https://community.homey.app/u/Maven)\
**Post date:** [August 8, 2023, 11:50am UTC](https://community.homey.app/t/how-to-send-push-notifications-with-my-app/86397/7 "2023-08-08T11:50:07Z")

</div>

@Jero could you maybe advice on my issue?

I’m on the new Homey Pro 2023. Am I missing something in the code or might this be related to the ongoing changes as outlined in [https://community.homey.app/t/sending-notification-will-not-work-in-homeyscript/79235/5](https://community.homey.app/t/sending-notification-will-not-work-in-homeyscript/79235/5) .

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [August 8, 2023, 12:32pm UTC](https://community.homey.app/t/how-to-send-push-notifications-with-my-app/86397/8 "2023-08-08T12:32:11Z")

</div>

Are you using `homey-api` already with the code I outlined/linked to?

---

<div class="post-metadata">

**Author:** ![Jero](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jero/32/17556_2.png) [@Jero](https://community.homey.app/u/Jero)\
**Post date:** [August 8, 2023, 1:05pm UTC](https://community.homey.app/t/how-to-send-push-notifications-with-my-app/86397/9 "2023-08-08T13:05:25Z")

</div>

An app is not allowed to start Flow card actions.

---

<div class="post-metadata">

**Author:** ![Maven](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/maven/32/110403_2.png) [@Maven](https://community.homey.app/u/Maven)\
**Post date:** [August 8, 2023, 1:19pm UTC](https://community.homey.app/t/how-to-send-push-notifications-with-my-app/86397/10 "2023-08-08T13:19:43Z")

</div>

Yes, thanks. this all works as per the api guides.

---

<div class="post-metadata">

**Author:** ![Maven](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/maven/32/110403_2.png) [@Maven](https://community.homey.app/u/Maven)\
**Post date:** [August 8, 2023, 2:38pm UTC](https://community.homey.app/t/how-to-send-push-notifications-with-my-app/86397/11 "2023-08-08T14:38:41Z")

</div>

So no way to send push notifications to homey mobile trough a homey app? ☹

 ![dev](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/8/f8dde1e7d6cf029eeb4d293bf8cdd3bf3963cff8.png)

---

<div class="post-metadata">

**Author:** ![Jero](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jero/32/17556_2.png) [@Jero](https://community.homey.app/u/Jero)\
**Post date:** [August 8, 2023, 5:04pm UTC](https://community.homey.app/t/how-to-send-push-notifications-with-my-app/86397/12 "2023-08-08T17:04:04Z")

</div>

No, not sure how you already are so far in development without being able to test those cards. Although I like the app idea.

---

<div class="post-metadata">

**Author:** ![Maven](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/maven/32/110403_2.png) [@Maven](https://community.homey.app/u/Maven)\
**Post date:** [August 8, 2023, 6:16pm UTC](https://community.homey.app/t/how-to-send-push-notifications-with-my-app/86397/13 "2023-08-08T18:16:08Z")

</div>

Damn! thank you for your support though.  
I was just practising based on your videos. Its a fully working app except the scope bounce when sending the notification - thought I just missed something 😅.

This works wonders for me in HomeyScript so wanted to make it readily available. Guess ill trash it for now.
