When your user opens your app for the first time, it'll be registered with a unique ID on Pushbots, you can always use that id to identify the user and send push notificaitons.
To get the Pushbots ID you can use the following method:
For iOS
objective-c
[Pushbots getDevice:^(NSDictionary *device, NSError *error) {
if(device != nil){
NSLog(@"id: %s", [device valueForKey:@"_id"]);
}
}];
swift
Pushbots.getDevice { (device, error) in
if(device != nil){
let device_id = device?["_id"]
print(device_id! as! NSString)
}
}
For Android
//Register custom fields after user registered on PushBots
Pushbots.sharedInstance().idsCallback(new Pushbots.idHandler() {
@Override
public void userIDs(String userId, String registrationId) {
if (registrationId != null && userId != null){
Log.d("PB3", "PushBots ID:" + userId );
}
}
});
For Phonegap/Cordova
//Get user registrationId/token and userId on PushBots, with evey launch of the app even launching with notification
window.plugins.PushbotsPlugin.on("user:ids", function(data){
console.log("ID" + data.id);
});
For web:
PB.events.push(["onRegisteredOnPushBots", function(data){
console.log("ID:", data.userId);
}]);
Did this answer your question?