Reputation: 125
Is a React Native app and i use @react-native-firebase/dynamic-links version 7.1.0 (rnFirebase). On android my dynamic link work correctly. On ios with firebase test link work correctly (myUrl.page.link), but with a verified prefix url (myUrl) app are opened but my function dynamicLinks().getInitialLink() return null. (I have add correctly url on associated domains in xcode)
I created the link with
const link = await dynamicLinks().buildShortLink(
{
link: encodeURI(
`myUrl/${list.generatedString}`
),
domainUriPrefix: 'myUrl',
analytics: {
campaign: 'banner'
},
navigation: {
forcedRedirectEnabled: false,
},
ios: {
bundleId: 'com.runeapp.gift-it',
// customScheme: 'giftit',
appStoreId: '1503678456'
},
android: {
packageName: 'com.runeapp.giftit'
}
},
'SHORT'
);
I wonder if the problem can be derived from the fact that the app has not yet been published on the app store.
Anyone have any idea? thanks
Upvotes: 2
Views: 6669
Reputation: 1
#import <RNFBDynamicLinksAppDelegateInterceptor.h> // add this line
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[RNFBDynamicLinksAppDelegateInterceptor sharedInstance]; // add this line
//-------
// other code
//-------
}
>
Upvotes: 0
Reputation: 325
My issue was because I'm using API key restriction for the API key I use in my application. I extended the restriction to allow usage with the Firebase Dynamic Links API.
To allow your API key in question to be used with the new Firebase Dynamic Links API:
APIs & Services
-> Credentials
API restrictions
sectionFirebase Dynamic Links API
Save
wait a couple of minutes for Google servers to update and retry...
Upvotes: 2
Reputation: 133
dynamicLinks().getInitialLink()
doesn't seem to work on iOS but here is a simple workaround I used in solving that:
When a user is on an iOS device, use the Linking package in react-native, then use the dynamicLinks().resolveLink()
passing the URL returned from Linking. getInitialURL()
, which would return the same response as dynamicLinks().getInitialLink()
. Here is a snippet:
if (Platform.OS === 'ios') {
Linking.getInitialURL()
.then(res => {
dynamicLinks().resolveLink(res).then(response => {
console.log(response.url);
})
})
}
You could use the value from the Linking library directly but it is helpful to call the dynamic link resolveLink() in case you added extra parameters while building your link.
Upvotes: 10
Reputation: 8541
When you open the app from the background you need to call onLink instead of getInitialLink
Upvotes: 1