flutter-webrtc / callkeep

iOS CallKit and Android ConnectionService for Flutter
MIT License
133 stars 147 forks source link

callKeep.setup throws type 'Null' is not a subtype of type 'List<String>' in type cast #99

Closed cdg720 closed 3 years ago

cdg720 commented 3 years ago

Hi,

When I call await callKeep.setup(null, callSetup); I get the following error messages

I/flutter ( 9569): FlutterFire Messaging: An error occurred in your background messaging handler:
I/flutter ( 9569): type 'Null' is not a subtype of type 'List<String>' in type cast

Longer code, which basically I copied from the example:

Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {
  await Firebase.initializeApp();
  final callKeep = FlutterCallkeep();
  final callSetup = <String, dynamic>{
    'ios': {
      'appName': 'CallKeepDemo',
    },
    'android': {
      'alertTitle': 'Permissions required',
      'alertDescription':
      'This application needs to access your phone accounts',
      'cancelButton': 'Cancel',
      'okButton': 'ok',
      // Required to get audio in background when using Android 11
      'foregroundService': {
        'channelId': 'com.company.my',
        'channelName': 'Foreground service for my app',
        'notificationTitle': 'My app is running on background',
        // 'notificationIcon': 'Path to the resource icon of the notification',
      },
    },
  };
  await callKeep.setup(null, callSetup);
}

Does anyone know what is causing this problem?

In my pubspec.yaml, I have:

callkeep: ^0.3.1
firebase_messaging: ^10.0.4
flutter doctor -v
[✓] Flutter (Channel stable, 2.2.3, on Linux, locale en_US.UTF-8)
    • Flutter version 2.2.3 at /home/dokook/development/tools/flutter
    • Framework revision f4abaa0735 (6 weeks ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /home/dokook/Android/Sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /snap/android-studio/current/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /snap/android-studio/114/android-studio
    • Flutter plugin version 59.0.2
    • Dart plugin version 203.8292
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] Android Studio
    • Android Studio at /snap/android-studio/current/android-studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = /snap/android-studio/current/android-studio
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] Connected device (2 available)
    • SM A125M (mobile) • R58R35SVWQL • android-arm64  • Android 11 (API 30)
    • Chrome (web)      • chrome      • web-javascript • Google Chrome 92.0.4515.131
cdg720 commented 3 years ago

setup expects 'additionalPermissions': <String>[] and now I am getting the following errors:

E/flutter (13208): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: PlatformException(E_ACTIVITY_DOES_NOT_EXIST, Activity doesn't exist, null, null)
E/flutter (13208): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:597:7)
E/flutter (13208): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158:18)
E/flutter (13208): <asynchronous suspension>
E/flutter (13208): #2      FlutterCallkeep._checkPhoneAccountPermission (package:callkeep/src/api.dart:325:16)
E/flutter (13208): <asynchronous suspension>
E/flutter (13208): #3      FlutterCallkeep._setupAndroid (package:callkeep/src/api.dart:302:30)
E/flutter (13208): <asynchronous suspension>
E/flutter (13208): #4      FlutterCallkeep.setup (package:callkeep/src/api.dart:39:7)
E/flutter (13208): <asynchronous suspension>
E/flutter (13208): 

It seems like I am missing actual additionalPermissions but I am not sure which ones.

cdg720 commented 3 years ago

I will close this since the title error went away even though setup still doesn't work for me.

rlee1990 commented 3 years ago

@cdg720 I am also having the same error

rlee1990 commented 3 years ago

@cloudwebrtc any idea on this?

cdg720 commented 3 years ago

@rlee1990 i got an example working with the latest firebase and null-safety. you may want to check https://github.com/cdg720/callkeep out

rlee1990 commented 3 years ago

@cdg720 thanks I will check it out.