I recently started using OneSignal to send notifications on my firebase based iOS project.
While I can send notifications to specific user and an array of users fine, I can't find documentation on how to set up OneSignal authentication with Firebase so that I can target a specific segment of users automatically through the app.
The code that I am using to send notifications to an array of users (working fine):
//to remove the current user ("playerID") from receiving notification
let indexToDelete = playerIDArray.index(of: playerID)
playerIDArray.remove(at: indexToDelete!)
var count = 0
while count < playerIDArray.count {
OneSignal.postNotification(["contents" : ["en" : "\(usersID!) has sent a message"], "include_player_ids" : ["\(playerIDArray[count])"]])
count = count+1
}
However, when I try to send the notification to a segments, like so:
OneSignal.postNotification(["contents" : ["en" : "\(usersID!) has sent a message"], "included_segments" : ["All"]])
I get this error:
2017-03-09 02:35:30.989 MyApp[3658:87978] ERROR: Create notification failed
I know that I am getting this error due to authorization issues, so I was wondering if anyone knows how to set up this authorization using Firebase?
Thanks so much!