Onesignal-flutter-sdk: Error Heads-up notification is not displayed in Android

Created on 1 Jul 2021  路  2Comments  路  Source: OneSignal/OneSignal-Flutter-SDK

Description:*

Error Heads-up notification is not displayed in Android:
When I update version 3.0.0 oneSignal on Android the Heads-up notification is not displayed, but on IOS it is working fine.

Environment

flutter doctor
bash [鉁揮 Flutter (Channel stable, 2.2.2, on macOS 11.2.3 20D91 darwin-x64, locale en-CO) [鉁揮 Android toolchain - develop for Android devices (Android SDK version 30.0.3) [鉁揮 Xcode - develop for iOS and macOS [鉁揮 Chrome - develop for the web [鉁揮 Android Studio (version 4.2) [鉁揮 IntelliJ IDEA Community Edition (version 2021.1.2) [鉁揮 VS Code (version 1.57.1) [鉁揮 Connected device (2 available)

pubspec
```yaml
name: xxxxxx
description: xxxxx

environment:
sdk: 2.13.3
flutter: 2.2.2

dependencies:
flutter:
sdk: flutter

onesignal_flutter: ^3.0.0

```

Steps to Reproduce Issue:

  1. Create a notification at https://app.onesignal.com/apps/xxx/notifications/newt
  2. Send notification
  3. When it arrives only sounds and is not displaying Heads-up notification when the user is using the smart phone.

    Setup OneSignal:

     Future<void> init() async {
    await OneSignal.shared.setLogLevel(OSLogLevel.error, OSLogLevel.none);
    await OneSignal.shared.setRequiresUserPrivacyConsent(false);
    
     _initListeners();
    
     await OneSignal.shared.setAppId(_oneSignalAppId);
    }
    
    
    void _initListeners() {
    OneSignal.shared.setNotificationWillShowInForegroundHandler((event) {
      event.complete(event.notification);
    
      final payload = event.notification;
    
      final properties = _mapPropertiesForAnalytics(payload);
    
    
      handleReceive(payload.additionalData);
    });
    }
    

    SEARCH EXISTING ISSUES FOR relating to the same topic but not describing : https://github.com/OneSignal/OneSignal-Flutter-SDK/issues/421

    Please help me :white_frowning_face:

Most helpful comment

Have you set up categories for Android?

With Android 8+ you must add these custom features through notification Categories aka Channels. You can set these in the Settings > Messaging tab.

You will want to set the Importance to Urgent to accomplish this.

More information on Android Categories here: https://documentation.onesignal.com/docs/android-notification-categories

All 2 comments

Have you set up categories for Android?

With Android 8+ you must add these custom features through notification Categories aka Channels. You can set these in the Settings > Messaging tab.

You will want to set the Importance to Urgent to accomplish this.

More information on Android Categories here: https://documentation.onesignal.com/docs/android-notification-categories

Yes, thank you very much. 馃
If, as I was sending it from one signal, I did not have it configured.

fixed.

Was this page helpful?
0 / 5 - 0 ratings