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

Time:02-10

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.

CodePudding user response:

  •  Tags:  
  • Related