Untitled
unknown
dart
2 years ago
1.5 kB
9
Indexable
WidgetsFlutterBinding.ensureInitialized();
OneSignal.shared.setAppId('76f9bb2d-642f-4285-a0e0-81804c3e11af');
final status = await OneSignal.shared.getDeviceState();
final String? osUserID = status?.userId;
debugPrint(osUserID.toString());
Push.getId().then((value) => print(value));
OneSignal.shared.setNotificationWillShowInForegroundHandler(
(OSNotificationReceivedEvent event) {
// Will be called whenever a notification is received in foreground
// Display Notification, pass null param for not displaying the notification
event.complete(event.notification);
});
OneSignal.shared
.setNotificationOpenedHandler((OSNotificationOpenedResult result) {
// Will be called whenever a notification is opened/button pressed.
});
OneSignal.shared.setPermissionObserver((OSPermissionStateChanges changes) {
// Will be called whenever the permission changes
// (ie. user taps Allow on the permission prompt in iOS)
});
OneSignal.shared
.setSubscriptionObserver((OSSubscriptionStateChanges changes) {
// Will be called whenever the subscription changes
// (ie. user gets registered with OneSignal and gets a user ID)
});
OneSignal.shared.setEmailSubscriptionObserver(
(OSEmailSubscriptionStateChanges emailChanges) {
// Will be called whenever then user's email subscription changes
// (ie. OneSignal.setEmail(email) is called and the user gets registered
});Editor is loading...