initialize static method
Implementation
static Future<void> initialize({
required final String uid,
}) async {
try {
final _deviceInfo = DeviceInfoPlugin();
String? _docId;
String? _platForm;
if (Platform.isAndroid) {
final _androidInfo = await _deviceInfo.androidInfo;
if (_androidInfo.androidId.isNotEmpty) {
_docId = _androidInfo.androidId;
}
_platForm = 'android';
} else if (Platform.isIOS) {
final _iosInfo = await _deviceInfo.iosInfo;
if (_iosInfo.identifierForVendor.isNotEmpty) {
_docId = _iosInfo.identifierForVendor;
}
_platForm = 'ios';
}
final _token = await _firebaseMessaging.getToken();
final _deviceRef = PeamanReferenceHelper.devicesCol(uid: uid).doc(_docId);
await _deviceRef.set({
'id': _deviceRef.id,
'token': _token,
'platform': _platForm,
'created_at': DateTime.now().millisecondsSinceEpoch,
});
print('Success: Initializing firebase messaging');
} catch (e) {
print(e);
print('Error!!!: Initializing firebase messaging');
}
}