I'm having problems integrating this plugin (4.0.4+300) into my existing flutter application. I always get the following error when initializing the plugin in this code:
TokenEventChannel.receiveBroadcastStream()
.listen(_onTokenEvent, onError: _onTokenError);
The following MissingPluginException was thrown while activating platform stream on channel com.huawei.flutter.push/token: MissingPluginException(No implementation found for method listen on channel com.huawei.flutter.push/token)
I/flutter ( 7674): When the exception was thrown, this was the stack: I/flutter ( 7674): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7) I/flutter ( 7674): I/flutter ( 7674): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12) I/flutter ( 7674): #2 EventChannel.receiveBroadcastStream. (package:flutter/src/services/platform_channel.dart:519:29) I/flutter ( 7674): #3 EventChannel.receiveBroadcastStream.
I have followed this tutorial: https://medium.com/huawei-developers/sending-push-notifications-on-flutter-with-huawei-push-kit-plugin-534787862b4d
My application already includes the FCM push notification services, so I don't know if that could be a problem? I'd like to support both FCM and Push Kit on supported devices.
I'd appreciate any help resolving this issue.
Flutter doctor output is as follows: [✓] Flutter (Channel stable, v1.17.5, on Mac OS X 10.15.6 19G2021, locale en-ZA) • Flutter version 1.17.5 at /Users/user/Developer/flutter • Framework revision 8af6b2f038 (9 weeks ago), 2020-06-30 12:53:55 -0700 • Engine revision ee76268252 • Dart version 2.8.4
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3) • Android SDK at /Users/user/Library/Android/sdk • Platform android-30, build-tools 29.0.3 • ANDROID_HOME = /Users/samuel/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211) • All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.6) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 11.6, Build version 11E708 • CocoaPods version 1.9.2
[✓] Android Studio (version 3.6) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 45.1.1 • Dart plugin version 192.8052 • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
[✓] VS Code (version 1.48.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.13.2
[✓] Connected device (1 available) • Android SDK built for x86 64 • emulator-5554 • android-x64 • Android 9 (API 28) (emulator)
• No issues found! Process finished with exit code 0
My Gradle dependencies and plugins in app/build.gradle:
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.firebase:firebase-core:17.4.4'
implementation 'com.google.firebase:firebase-messaging:20.2.3'
implementation 'com.google.firebase:firebase-analytics:17.4.4'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply plugin: 'com.huawei.agconnect'
And in android/build.gradle:
dependencies {
// Example existing classpath
classpath 'com.android.tools.build:gradle:3.5.3'
// Add the google services classpath
classpath 'com.google.gms:google-services:4.3.2'
classpath 'io.fabric.tools:gradle:1.26.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.huawei.agconnect:agcp:1.3.1.300'
}