devicePushTopic static method
A push topic that represents this device, used to send a push to only this device. @returns a future that completes with the device push topic.
Implementation
static Future<MPTopic> devicePushTopic() async {
String deviceId = '';
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
if (Platform.isAndroid) {
const androidIdPlugin = AndroidId();
String? androidId = await androidIdPlugin.getId();
deviceId = androidId ?? '';
} else {
IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
deviceId = iosInfo.identifierForVendor ?? '';
}
return MPTopic(
code: deviceId,
title: 'Device: $deviceId',
single: true,
);
}