I am using the getstream api and I would like to enable push notification services on both android and ios devices. The documentation just shows various excerpts on various parts of the process and I don't understand why. This is a nuanced topic and detailed step by step process should be the standard. But essentially, I am not sure how to add a device to a client.
I have tried the below (which i'm not sure is the right way to go about it, but the documentation is not clear) but I get an unauthorized token error:
_invokeGetStreamApiFcmToken() async {
final client = StreamChatCore.of(context).client;
//listen for fcm token refresh
FirebaseMessaging.instance.onTokenRefresh.listen((token) {
client.addDevice(token, PushProvider.firebase);
print("get stream api token refreshed -- $token");
});
print(await FirebaseMessaging.instance.getToken());
print(await FirebaseMessaging.instance.getAPNSToken());
// register the device with APN (Apple only)
await client.addDevice(uid, PushProvider.apn);
// register the device with Firebase (Android only)
await client.addDevice(uid, PushProvider.firebase);
print(await client.getDevices());
}
In the client.addDevice() method, I am not sure at all what the first parameter, "device id" is meant to be. How do i get this device ID?