简体   繁体   中英

Dynamic Links Working on iOS, and Android Can Receive Them But Not Generate One

I am working on implementing Firebase dynamic links within my project. I have followed the guide here which does a great job of walking through the process. I have updated my manifest and plist files, however I am still having trouble with Android generating a dynamic link.

Both iOS and Android are able to receive dynamic links, which is automatically open the app in the expected behavior. I am also able to generate the dynamic link in iOS successful and use it in iOS and Android. However, when I try to generate the dynamic link on an Android device I am receiving the error:

E/flutter ( 7378): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(short_link_error, 17: API: DynamicLinks.API is not available on this device. Connection failed with: ConnectionResult{statusCode=SERVICE_INVALID, resolution=null, message=null}, null, null)

I am generating the link like so:

Future<Uri> createDynamicLink(String id) async {
    final DynamicLinkParameters parameters = DynamicLinkParameters(
      uriPrefix: 'https://example.page.link',
      link: Uri.parse('https://example.com/?id=$id'),
      androidParameters: AndroidParameters(
        packageName: 'com.example.example',
        minimumVersion: 1,
      ),
      iosParameters: IosParameters(
        bundleId: 'com.example.example',
        minimumVersion: '1',
        appStoreId: '1223432',
      ),
    );
    var dynamicUrl = await parameters.buildShortLink();
    final Uri shortUrl = dynamicUrl.shortUrl;
    return shortUrl;
  }

And implementing it on a page:

Align(
  alignment: AlignmentDirectional(0, 0),
    child: FlutterFlowIconButton(
     icon: Icon(
     Icons.send_sharp,
   ),
     onPressed: () async {
       var uri = await _dynamicLinkService.createDynamicLink('firsttest');
       await Share.share(uri.toString());
       print(uri.toString());
  },
 ),
),

I should also note that the Android emulator has internet, so that doesn't appear to be the problem either. I have tried this on a Nexus S and Pixel 5 API 30 emulators with the same error message.

Update : I finally figured it out. I had to use an emulator with an API=32, which I guess the dynamic links API can work with. Figured I would leave this up here in case anyone else runs into this problem.

In first time i'm use android device with custom firmware (Xiaomi Mix 3 5g Lineage OS 12), this firmware included google services, but i'm catch this bug. In next time i'm try use dynamic links on google emulator with google services and on this all work fine. Im think this problem associated with google services in OS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM