Hugo Deiró
Hugo Deiró

Reputation: 224

How to define OneSignal Segments through application

I need to define a custom segments through application using OneSignal. I want to know if this is possible.

For example, when I initialize the application I need a way to send the custom segments to OneSignal API like:

createCustomSegment({key:"cars", value:"Cars"});

If the segment doesn't exists it creates and subscribe the user. If exists, just subscribe.

If this is not possible, theres a way I can add the user to an segment through application?

Upvotes: 1

Views: 521

Answers (1)

jkasten
jkasten

Reputation: 3948

OneSignal Segments can only be created on the dashboard, you can setup them up to look for specific tag keys and values. Then use window.plugins.OneSignal.sendTags to tag the device from your app.

Instead of creating Segments you can use the 'tags' field on the OneSignal create notification REST API call.

Upvotes: 2

Related Questions