I'm using onesignal to handle pish notification for both my web and ionic app. My question is
Can I setup user segments using server rest api ?
I want to give my users ability to subscribe to specific events (channels) to limit push notifications they receive.
Example
user1 subscribed to group I'd (1,3,8)
user2 groups(5,8,11)
User3 groups(12,13)
When event happened on groups 8.
How can I send push notifications to all users subscribed to group 8 ? -in my example above notification should be sent to user1 & user2 but not 3.
OneSignal doesn't currently support dynamically creating segments through the API, however there is a better way to do what you need.
You can use the tags feature to assign custom data to users, and then you can deliver notifications to users who match specific tags. Tags are typically set by calling the SetTags method in your app, but they can also be set through the OneSignal API.
In your case, for instance, you would assign the following tags to each user:
User1 Tags: group1=true,group3=true,group8=true
User2 Tags: group5=true,group8=true,group3=true
User3 Tags: group12=true,group13=true
Next, through the OneSignal API, you can use the "tags" field to only deliver your notifications to users who match one or more tags.
You could also create a segment for each tag on the dashboard, then through the API or through the dashboard you could specify which segments (and therefore tags) should receive your notification.