Untitled
faisalsalameh
dart
a year ago
1.8 kB
0
Indexable
Never
Future<void> initPlatformState() async { await OneSignal.shared.setLogLevel(OSLogLevel.verbose, OSLogLevel.none); await OneSignal.shared.setAppId(appID); await OneSignal.shared .promptUserForPushNotificationPermission() .then((bool accepted) {}); await OneSignal.shared.getDeviceState().then((OSDeviceState? deviceState) { this.deviceState = deviceState; log('DeviceState: ${deviceState?.jsonRepresentation()}'); }); 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); }); await OneSignal.shared.sendTags(ss); OneSignal.shared .setNotificationOpenedHandler((OSNotificationOpenedResult result) { // Will be called whenever a notification is opened/button pressed. log('result: ${result.notification.title}'); }); // handleSendNotification(); OneSignal.shared.setNotificationOpenedHandler( (OSNotificationOpenedResult openedResult) { log('Opened Result: ${openedResult.notification.title}'); setTypeNotification(openedResult); }, ); 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 }); }