'Why Firebase dynamic link is always null?
I created a Dynamic link through createDynamicLink
that is inside the class DynamicLinkService
, after this I use retrieveDynamicLink
for the part of reading the link that is opened from the android browser, but it prints that it is null, therefore it does not enter the if and does not push to another route inside the if
class DynamicLinkService {
Future<void> retrieveDynamicLink(BuildContext context) async {
try {
final PendingDynamicLinkData? data =
await FirebaseDynamicLinks.instance.getInitialLink();
final Uri? deepLink = data?.link;
print("deepLink: $deepLink");
if (deepLink != null) {
print("deepLink If: $deepLink");
String deepLinks = deepLink.toString();
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => linkInvitacionScreen(deepLinks)));
}
} catch (e) {
print(e.toString());
}
}
Future<String> createDynamicLink(String groupID) async {
final DynamicLinkParameters parameters = DynamicLinkParameters(
uriPrefix: 'https://notforget.page.link/',
link: Uri.parse(
'https://notforget.com/groupid?$groupID'),
androidParameters: const AndroidParameters(
packageName: 'com.example.not_forget_flutter',
minimumVersion: 1,
),
);
final ShortDynamicLink shortDynamicLink =
await FirebaseDynamicLinks.instance.buildShortLink(parameters);
final Uri shortUrl = shortDynamicLink.shortUrl;
print(shortUrl);
return shortUrl.toString();
}
}
intent filter of AndroidManifest
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- Deep linking -->
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="notforget.page.link" />
<data android:scheme="https" />
</intent-filter>
</activity>
i tried various solutions but none led me to get a value in deeplink
, what am i doing wrong?, thanks.
Solution 1:[1]
Replace Your Host From android:host="notforget.page.link" To android:host="notforget.page.link"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Emon Code |