AppGalleryConnect / agc-flutter-plugin

This repository including all of exsiting plugins of AppGallery Connect Service in Flutter.
Apache License 2.0
12 stars 3 forks source link

Error Opening app links #6

Closed akfrancisco closed 2 years ago

akfrancisco commented 2 years ago
StreamSubscription<ResolvedLinkData> _streamSubscription;
 final AGCAppLinking s= new AGCAppLinking();
initState() {
    super.initState();

    _streamSubscription = agcAppLinking.onResolvedData.listen((event) {
      _showDialog(context, event.toString());
    });
  }

with the ff. exception

E/EventChannel#com.huawei.agc.flutter.applinking_eventchannel(13585): Failed to close existing event stream
E/EventChannel#com.huawei.agc.flutter.applinking_eventchannel(13585): java.lang.IllegalArgumentException: Receiver not registered: null
E/EventChannel#com.huawei.agc.flutter.applinking_eventchannel(13585):   at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:1523)
E/EventChannel#com.huawei.agc.flutter.applinking_eventchannel(13585):   at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1712)
E/EventChannel#com.huawei.agc.flutter.applinking_eventchannel(13585):   at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:733)
E/EventChannel#com.huawei.agc.flutter.applinking_eventchannel(13585):   at com.huawei.agc.flutter.applinking.handlers.AppLinkingStreamHandler.onCancel(AppLinkingStreamHandler.java:45)
E/EventChannel#com.huawei.agc.flutter.applinking_eventchannel(13585):   at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onListen(EventChannel.java:182)
E/EventChannel#com.huawei.agc.flutter.applinking_eventchannel(13585):   at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onMessage(EventChannel.java:167)
E/EventChannel#com.huawei.agc.flutter.applinking_eventchannel(13585):   at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/EventChannel#com.huawei.agc.flutter.applinking_eventchannel(13585):   at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/EventChannel#com.huawei.agc.flutter.applinking_eventchannel(13585):   at android.os.MessageQueue.nativePollOnce(Native Method)
E/EventChannel#com.huawei.agc.flutter.applinking_eventchannel(13585):   at android.os.MessageQueue.next(MessageQueue.java:335)
E/EventChannel#com.huawei.agc.flutter.applinking_eventchannel(13585):   at android.os.Looper.loop(Looper.java:206)
E/EventChannel#com.huawei.agc.flutter.applinking_eventchannel(13585):   at android.app.ActivityThread.main(ActivityThread.java:8550)
E/EventChannel#com.huawei.agc.flutter.applinking_eventchannel(13585):   at java.lang.reflect.Method.invoke(Native Method)
E/EventChannel#com.huawei.agc.flutter.applinking_eventchannel(13585):   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
E/EventChannel#com.huawei.agc.flutter.applinking_eventchannel(13585):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
I/ViewRootImpl@8b8ac36[MainActivity](13585): [DP] pdf(0) 1 android.view.ViewRootImpl.lambda$performDraw$1$ViewRootImpl:4681 android.view.-$$Lambda$ViewRootImpl$DJd0VUYJgsebcnSohO6h8zc_ONI.run:6 android.os.Handler.handleCallback:938
I/ViewRootImpl@8b8ac36[MainActivity](13585): [DP] rdf()
E/com.huawei.agc.flutter.applinking.handlers.AppLinkingStreamHandler(13585):  code: 1 message: no intent data
akfrancisco commented 2 years ago

Not an issue, error on my part.

reopening issue, still throwing the problem

aldrin233 commented 2 years ago

A work around for this problem is get another library that accesses the intent data.

using app_links

Future<void> handleDeepLink(){
 final _appLinks = AppLinks(onAppLink: (uri,uristring){});
    await _appLinks.getInitialAppLink();

final agcAppLinking = AGCAppLinking();

// eventStream is mishandled/broken so we use the call above
agcAppLinking.onResolvedData.listen((event) async { 
   // Do something here 
}

}
huseyinerenguler commented 2 years ago

Hi @akfrancisco

We noticed the issue you mentioned and we are working on solutions. We will fix that in the next major release.

For now, you can follow the steps below.

  1. Open your project's android side with Android Studio.
  2. Select agconnect_applinking from the left menu.
  3. Go to this path: java/com/huawei/agc/flutter/applinking/handlers/AppLinkingStreamHandler.java
  4. Comment out this line: mActivity.unregisterReceiver(null);
Screen Shot 2022-02-28 at 13 50 12
huan721 commented 2 years ago

Hi @akfrancisco Is huseyinerenguler's answer okay? If there is no problem, please close the problem first:)

aldrin233 commented 2 years ago

Both @huseyinerenguler and a quickfix by using another library to interpret the deeplinks work.