onesignal-node-api icon indicating copy to clipboard operation
onesignal-node-api copied to clipboard

[Bug]: Can't create notifications targeting a list of external ids

Open remiremi opened this issue 2 years ago • 29 comments
trafficstars

What happened?

The REST API makes it possible to send notifications to a list of users given their external ids: https://documentation.onesignal.com/reference/create-notification#platform-to-deliver-to

However the sdk doesn't seem to make it possible, because the field include_aliases expects an object of type PlayerNotificationTargetIncludeAliases, which definition doesn't make it possible to define the external_id field.

This is what the serialized JSON for include_aliases should look like according to REST API documentation

  "include_aliases": {
    "external_id": ["external_user_id_on_push_email_sms"]
  },

Steps to reproduce?

Install latest version of sdk.

To try and make the call with the SDK, run:

    const notification = new OneSignal.Notification()
    notification.app_id = this.appId
    notification.include_aliases = new OneSignal.PlayerNotificationTargetIncludeAliases();
    notification.include_aliases.external_id = ["my-id-1", "my-id-2"]

Typescript will complain that

"Property 'external_id' does not exist on type 'PlayerNotificationTargetIncludeAliases'.ts(2339)"

What did you expect to happen?

I expect the SDK to have the correct type definition of PlayerNotificationTargetIncludeAliases so that the API call can be made with the correct parameters.

Relevant log output

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

remiremi avatar Aug 15 '23 15:08 remiremi

I'm getting this error as well. The typescript types are wrong

alexrabin avatar Aug 17 '23 04:08 alexrabin

@remiremi @alexrabin could you share which version of the SDK you're using?

iAmWillShepherd avatar Aug 31 '23 16:08 iAmWillShepherd

@remiremi @alexrabin could you share which version of the SDK you're using?

I am using 2.0.1-beta2

alexrabin avatar Aug 31 '23 16:08 alexrabin

@remiremi

I am using 2.0.1-beta2

I suspected that, but I just wanted to confirm. Thanks for the prompt reply 🙏🏽

iAmWillShepherd avatar Aug 31 '23 16:08 iAmWillShepherd

I'm working on reproducing this now in my sample project. Once I reproduce there, I can start to build additional context to understand what's going wrong and how we can fix our typings.

iAmWillShepherd avatar Aug 31 '23 16:08 iAmWillShepherd

@iAmWillShepherd thanks for looking into this!

alexrabin avatar Aug 31 '23 16:08 alexrabin

I reproduce this issue, and the team is aware of the problem. However, I have little insight into when a fix will be available.

╭─iamwill@kronos ~/code/@onesignalDevelopers/OneSignal-Node-Sample ‹main●› 
╰─$ ./bin/dev notification create -A 202d4f61-1ca9-42df-9d36-bb17d8613abf --name "Include EUID test" -- "Did it work"
Sending push notification... done
{
  "id": "",
  "errors": {}
}

@remiremi

notification.include_aliases.external_id = ["my-id-1", "my-id-2"]

You're 100 percent correct that this isn't possible. The only property you can access is alias_label.

Did you try including EIDs via the Notification.include_external_user_ids property?

const notification = new OneSignal.Notification()
notification.include_external_user_ids = ['id1', 'id2', 'id3']

iAmWillShepherd avatar Aug 31 '23 19:08 iAmWillShepherd

@iAmWillShepherd Yes I am however the documentation says the attribute is deprecated:

DEPRECATED: Use include_aliases with target_channel instead.

https://documentation.onesignal.com/reference/create-notification#send-to-specific-devices

alexrabin avatar Aug 31 '23 19:08 alexrabin

@iAmWillShepherd Yes I am however the documentation says the attribute is deprecated:

DEPRECATED: Use include_aliases with target_channel instead.

https://documentation.onesignal.com/reference/create-notification#send-to-specific-devices

They are indeed being deprecated, however, they should still be available to use until we ship an updated SDK.

iAmWillShepherd avatar Aug 31 '23 20:08 iAmWillShepherd

@iAmWillShepherd Yes the attribute does currently work but I'd rather not use an attribute that is deprecated.

alexrabin avatar Aug 31 '23 20:08 alexrabin

@iAmWillShepherd Yes the attribute does currently work but I'd rather not use an attribute that is deprecated.

I understand. However, the property is not deprecated yet. It's marked as Deprecating, so it's a warning that it will be deprecated in the future and subsequently not supported some time after the official deprecation takes place.

If you're OK with waiting indefinitely, we will ship an SDK that enables you to avoid using the deprecated property. My suggestion was meant to unblock you today. A fix will likely not be released at any point this week.

iAmWillShepherd avatar Aug 31 '23 20:08 iAmWillShepherd

@iAmWillShepherd I understand. Thank you

alexrabin avatar Aug 31 '23 20:08 alexrabin

I am stuck on the same problem, but I want to include the onesignal_id alias rather than external_id. What is the work around for that please?

kpturner avatar Aug 31 '23 22:08 kpturner

They are indeed being deprecated, however, they should still be available to use until we ship an updated SDK.

@iAmWillShepherd Available, yes, but not workable in production. The invalid_external_user_ids has been removed from errors in the response and moved to warnings according to the docs. This appears to have changed on 6/2 from our logs.

Additionally, invalid_aliases doesn't exist on Notification200Errors. As I mentioned, invalid_external_user_ids does but your API doesn't even seem to return this anymore from my testing and your docs. It's now in warnings which doesn't appear to be accessible through the SDK.

What's the ETA for this being wired up properly?

Thanks!

jpignata avatar Oct 14 '23 16:10 jpignata

This is still an issue, We've tried to do the migration today but faced the type issues described in the comments. Any ETA on this?

manueltwistag avatar Oct 16 '23 14:10 manueltwistag

This SDK is undergoing another overhaul with more clear types and method names. The development for it is in progress and active and this issue is a priority

emawby avatar Oct 19 '23 16:10 emawby

I see the development in progress and commenting to add more visibility as I too am blocked by this issue. Thanks!

abeisleem avatar Oct 21 '23 10:10 abeisleem

Heya - any progress here to report? I'd like to resume being able to report on failed push notifications.

jpignata avatar Nov 13 '23 16:11 jpignata

@emawby Sorry to be a pain. Do you have an expected release date, so I can fix the bug on my end that this change caused?

jpignata avatar Dec 01 '23 22:12 jpignata

Will it be released anytime soon?

padejar avatar Dec 27 '23 06:12 padejar

@iAmWillShepherd @emawby any update? The situation is very unclear

michalstruck avatar Dec 27 '23 17:12 michalstruck

I am also blocked on this. Using include_aliases with external_id does nothing and include_external_user_ids gives a Bad Request HTTP error.

deepadoshi avatar Jan 31 '24 20:01 deepadoshi

It's beyond belief that an issue that's 5 months old has had no progress. I'm inclined to believe this repo isn't maintained, which is understandable for some open source projects but this is supposed to be OneSignal's official node SDK 🤷‍♀️

kpturner avatar Jan 31 '24 23:01 kpturner

These are still the most up-to-date comments of this post:

https://github.com/OneSignal/onesignal-node-api/issues/66#issuecomment-1701688862

https://github.com/OneSignal/onesignal-node-api/issues/66#issuecomment-1771307881

These backend SDKs are going to take more time so they can be implemented correctly.

For now, if you want to target External IDs, continue using the Notification.include_external_user_ids property.

jfishman1 avatar Feb 06 '24 21:02 jfishman1

I received this generic error when I try to create a notification:

CreateNotificationSuccessResponse { id: '', errors: Notification200Errors {} }

I read that it is necessary to create a segment. It is possible to insert an array of ids in segment and after creating a notification it is necessary to use the id of segment how reference, but my account is free and it is impossible to create segment in free account. If someone to found the solution, please, talk me.

MatheusLima7 avatar Mar 06 '24 15:03 MatheusLima7

I've never had to create a segment to send notifications. There is a default segment for everything anyway AFAIK

kpturner avatar Mar 06 '24 16:03 kpturner

I've never had to create a segment to send notifications. There is a default segment for everything anyway AFAIK

I am trying a method of resolve the problem, because include_external_user_ids not works for me.

MatheusLima7 avatar Mar 06 '24 17:03 MatheusLima7

This should work with 5.0.0-alpha.1 now.

The important change is this: https://github.com/OneSignal/onesignal-node-api/commit/86801beb8c074f1a9c7593e199a558e9a1506298#diff-2541f67df3dacc0f2f4754190bdf4b5ab7670412a7c8fb9d6994220a077106feR63-R66

But worth to mention about this new alpha version:

Documentation on API changes is lacking and under progress. The README is outdated for this release.

EinfachHans avatar May 03 '24 08:05 EinfachHans

Hi everyone, thanks again for reporting and for your patience.

As @EinfachHans mentioned, we recently released an alpha version of our latest user model API: Release 5.0.0-alpha-01 that addresses this and other issues.

Please read the release description for how to get started, and we appreciate any early feedback on this release.

nan-li avatar May 09 '24 22:05 nan-li