OneSignal / OneSignal-Flutter-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your flutter app with OneSignal
https://www.onesignal.com
Other
616 stars 213 forks source link

Unable to get FCM Token #433

Closed Goolpe closed 2 years ago

Goolpe commented 3 years ago

Description:

Implementation of onesignal in release mode (app/build.gradle): some devices show errors (screenshots below: first or second). Debug mode: no dialogs with error, notifications come, but setNotificationWillShowInForegroundHandler doesnt work

Errors: Honor 20 pro, Xiaomi redmi note 9 pro Works fine: Honor 9X, Xiaomi redmi 4x, HUAWEI P smart, Xiaomi redmi note 8 pro

P.S. Absent any firebase dependencies

Environment

onesignal_flutter: ^3.0.0

Steps to Reproduce Issue:

  1. Set code
    
    import 'package:flutter/material.dart';
    import 'package:onesignal_flutter/onesignal_flutter.dart';

void main() => runApp(const Application());

class Application extends StatefulWidget { const Application({Key? key}) : super(key: key);

@override _ApplicationState createState() => _ApplicationState(); }

class _ApplicationState extends State {

@override void initState() { init(); super.initState(); }

@override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text('Test'), TextButton( onPressed: connect, child: Text('connect') ), TextButton( onPressed: disconnect, child: Text('disconnect') ) ], ), ), ), ); }

Future init() async { OneSignal.shared.setLogLevel(OSLogLevel.verbose, OSLogLevel.error);

OneSignal.shared.setNotificationWillShowInForegroundHandler((OSNotificationReceivedEvent event) {
  event.complete(event.notification);
});
await OneSignal.shared.setAppId(AppID);

}

void connect(){ OneSignal.shared.setExternalUserId(UserID); }

void disconnect(){ OneSignal.shared.removeExternalUserId(); } }


2. Update app/build.gradle

buildscript { repositories { maven { url 'https://plugins.gradle.org/m2/' } } dependencies { classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.10, 0.99.99]' } }

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin' ..

buildTypes { release { // or this signingConfig signingConfigs.debug signingConfig signingConfigs.release } }



**Screenshots:**

1. <img src="https://user-images.githubusercontent.com/18518522/125465349-8e361ebc-c2e7-4995-a0df-559b16f96666.png" height = 500> <img src="https://user-images.githubusercontent.com/18518522/125483815-bd7bbb8f-51bd-47e2-b31e-2169740a85ec.png" height = 500> 

2. <img src="https://user-images.githubusercontent.com/18518522/125466569-83630ed0-831e-4782-943a-efd9b0d0ebdb.png" height = 500> <img src="https://user-images.githubusercontent.com/18518522/125466430-fbcf5062-7eae-448b-b5b1-7ca8ba0ae289.png" height = 500>
jkasten2 commented 3 years ago

@Goolpe There could be another library in your project that also uses FCM and is initializing it that could be a result of some of these errors. The first screenshot does not seem to be from OneSignal, as OneSignal does not use the Default firebase app. The 2nd screenshot does seem to be from OneSignal as it has the named Firebase app name.

Could you also let us know what you have in your dependencies: section in your pubspec.yaml?

On the devices that are having these errors could check the version of the "Google play services" app under Settings > Apps? Could you also make sure those devices can open the Google "Play Store" to ensure it has the latest updates for this.

Could you also attach a full logcat from the device. This way we can see any other errors or warnings before these stack traces.

Goolpe commented 3 years ago

Unfortunately, can't attach logcat yet, dependencies:

  flutter:
    sdk: flutter
  assorted_layout_widgets: ^5.0.1
  connectivity: ^3.0.6
  double_back_to_close_app: ^2.0.1
  flutter_boom_menu:
    git:
      url: https://github.com/kuchienkz/flutter_boom_menu
  flutter_datetime_picker:
    git:
      url: https://github.com/Realank/flutter_datetime_picker.git
      ref: master
  flutter_localizations:
    sdk: flutter
  flutter_multi_formatter: ^2.3.1
  flutter_slidable: ^0.6.0
  flutter_spinkit: ^5.0.0
  flutter_svg: ^0.22.0
  get: ^4.1.4
  graphql_flutter: ^5.0.0
  hive: ^2.0.4 
  hive_flutter: ^1.1.0
  image_picker: ^0.8.1+3
  intl: ^0.17.0
  laravel_echo: 
    git:
      url: https://github.com/RizalMuhamadH/echo
  material_design_icons_flutter: ^5.0.5955-rc.1
  onesignal_flutter: ^3.0.0
  pin_code_fields: ^7.2.0
  quiver: ^3.0.1
  reorderables: ^0.4.1
  sentry_flutter: ^5.1.0 
  socket_io_client: 1.0.1
  timeago: ^3.1.0
  url_launcher: ^6.0.8
  geolocator: ^7.2.0+1
  location: ^4.3.0
  network_info_plus: ^1.0.2
  protoc_plugin: ^20.0.0
  wifi_iot: ^0.3.4

UPD: If run app in debug (flutter run) error isn't shown, only in apk logs.txt

@jkasten2, google play services Honor 20 pro:

UPD2: After adding android:allowBackup="false" to AndroidManifest, the error dialog disappeared. But subscription OneSignal.shared.setNotificationWillShowInForegroundHandler still doesnt work

emawby commented 2 years ago

@Goolpe Hello are you still experiencing this issue?

Goolpe commented 2 years ago

I am no longer working with this project and don’t know if there is an issue, so I close it.