francesco
(Francesco)
October 22, 2018, 8:27pm
1
Hi guys,
I need to get the complete list of the registered devices for push notification.
I know that there is a rest api to retrieve the device id and, with that code, get the related user.
But is there a method to get the device tokens of the unregistered user? I have a lot of people without account that are registered to the push notification channel. How can retrieve all those token?
Hello Francesco,
You can retrieve device tokens using data retrieval with the DeviceRegistration table.
Here is the Swift example for the default channel.
Dictionary/Map approach
let queryBuilder = DataQueryBuilder()!
queryBuilder.setWhereClause("channelName = 'default'")
let deviceStore = Backendless.sharedInstance()?.data.ofTable("DeviceRegistration")
deviceStore?.find(queryBuilder, response: { deviceRegistrations in
print("Devices: ")
for deviceRegistration in deviceRegistrations as! [[String : Any]] {
print(deviceRegistration["deviceToken"]!)
}
}, error: { fault in
print("Error: \(fault!)")
})
Class approach
let deviceStore = Backendless.sharedInstance()?.data.of(DeviceRegistration.ofClass())
deviceStore?.find(queryBuilder, response: { deviceRegistrations in
print("Devices: ")
for deviceRegistration in deviceRegistrations as! [DeviceRegistration] {
print(deviceRegistration.deviceToken!)
}
}, error: { fault in
print("Error: \(fault!)")
})
Regards,
Olga
francesco
(Francesco)
October 23, 2018, 12:21pm
3
Thank you for your reply but I’m using the old version of backendless…is it possible to retrieve tokens with the old version?