I try to get Url after install app from Google store.
if the application is installed and i click on link app open and function firebase.links().onLink work great. But if app not install i click on url go to android store install app and firebase.links().onLink not work. Also i try to use firebase.links().getInitialLink() it always return null.
url i use for install: https://rhx27.app.goo.gl/bCK1
full url: https://rhx27.app.goo.gl/?link=https://www.example.com/someresource&apn=com.example.android&amv=3&ibi=com.example.ios&isi=1234567&ius=exampleapp&d=1
`
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:name=".MainApplication"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<!--<data-->
<!--android:host="my_deep_link"-->
<!--android:scheme="app_code.app.goo.gl/?link=https" />-->
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.View" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="https://rhx27.app.goo.gl"
android:scheme="http" />
<data
android:host="https://rhx27.app.goo.gl"
android:scheme="https" />
<data
android:host="my_deep_link"
android:scheme="app_code.app.goo.gl/?link=https" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
`
my code:
componentDidMount() {
firebase.links()
.getInitialLink()
.then((url) => {
if (url) {
Alert.alert(
'Alert Title getInitialLink',
url,
[
{text: 'Cancel', onPress: () => console.log('Cancel Pressed'), style: 'cancel'},
{text: 'OK', onPress: () => console.log('OK Pressed')},
],
{cancelable: false}
)
} else {
// app NOT opened from a url
}
}).catch(e => Alert.alert('Alert Title error', e,
[
{text: 'Cancel', onPress: () => console.log('Cancel Pressed'), style: 'cancel'},
{text: 'OK', onPress: () => console.log('OK Pressed')},
],
{cancelable: false}
))
const unsubscribe = firebase.links().onLink((url) => {
Alert.alert(
'Alert Title onLink',
url,
[
{text: 'Cancel', onPress: () => console.log('Cancel Pressed'), style: 'cancel'},
{text: 'OK', onPress: () => console.log('OK Pressed')},
],
{cancelable: false}
)
})
}
full repository: https://github.com/romreed/DynamicLinks
Android 7.1.2
Application Target Platform:
macOS Sierra 10.12.6 (16G29)
Development Operating System:
Android Studio 3.0.1
Build Tools:
com.android.tools.build:gradle:3.1.2
React Native version:
"react-native": "0.55.4"
RNFirebase Version:
"react-native-firebase": "^4.1.0"
Firebase Module:
implementation "com.google.firebase:firebase-invites:15.0.1"
I'm having the same problem.
The url parameter of the getInitialLink promise returns null.
It used to work fine, but after upgrading, I've lost the ability to receive the url.
Here is how I've implemented my code:
firebase.links()
.getInitialLink()
.then((url) => {
console.log('THE URL: ', url);
this.handleDynamicLink(url);
});
Also firebase.links().onLink((url) is never fired, even if I open a dynamic link, while the app is in the background.
If I open a dynamic link, Android switches to the application correctly, but doesn't fire the onLink Event.
I managed to narrow it down a little.
When I use the long instead of short links, everything works perfectly fine.
It's really just the short link, that is not working.
I've also checked and added the certificate fingerprint to firebase console.
It is really weird. Any ideas?
I am using:
"react": "^16.3.1",
"react-native": "^0.53.9",
"react-native-firebase": "^4.1.0",
Any idea on how to debug this better or where to start with this?
My Objective C and Java knowledge is limited, but I don't mind digging into this.
Or what information can I provide to help work on this?
Is there maybe just a simple setting I am missing?
@SimonErich i use https://branch.io for deep link.
Thanks @SimonErich using long link works fine.
@SimonErich @gidox can you please explan what is long link?
I also get initiallink null after install. Please for some example?
@vvusts Firebase provides 2 types of links, one short and one long, the short would be something like pq58r.app.goo.gl/ug4K and the long link would be something like pq58r.app.goo.gl/?link=https awsomelink.com/home/&apn=com.hyper.bellezpa&isi=1174349708&ibi=com.Bellezpa.App&etcetc
My long link is like: https://myapp.page.link/?link=https://myapp.com/?code%3DGQUALI%26start%3Dtrue&apn=com.myapp.app&isi=1251208866&ibi=com.myapp.app
But same like short when press on link it open store I install app and open app link is null.
One strange thing on android store after install has “continue” button instead open and click onit become “open”.
I cannot manage to make it work either. Here is the step I follow :
let url = await firebase.links().getInitialLink()
this.logger.info("dynamic link", url)
and url is always null
My configuration :
react-native-firebase@^4.0.5:
Also another related problem: when the app is already installed, and I click on the same link, my app opens, but I get the deeplink from the onLink
callback, getInitialLink
returning null again
Please see if https://github.com/invertase/react-native-firebase/issues/1273 is relevant here. Also it's worth using Android Studio's App Links Assistant
to get the correct SHA256 to upload to the Firebase Console and to test it - it's very useful - see my comment on that issue.
when visiting https://funapplocal.page.link/.well-known/assetlinks.json I get (I changed the app name):
[{"relation":["delegate_permission/common.handle_all_urls"],"target":{"namespace":"android_app","package_name":"it.funapp.mob.debug","sha256_cert_fingerprints":["93:6C:ED:B7:BB:F9:3D:89:E6:87:D1:55:3A:88:BD:50:15:BD:38:95:B3:68:89:57:5F:88:4D:29:19:98:33:60"]}},{"relation":["delegate_permission/common.handle_all_urls"],"target":{"namespace":"android_app","package_name":"it.funapp.mob.dev","sha256_cert_fingerprints":["0D:8D:CB:98:A2:AB:4A:1D:53:B0:25:D0:E9:98:65:E0:07:BD:EC:AC:B0:12:00:EF:36:56:F3:71:D6:F4:F5:F2"]}},{"relation":["delegate_permission/common.handle_all_urls"],"target":{"namespace":"android_app","package_name":"it.funapp.mob","sha256_cert_fingerprints":["94:C4:A6:19:B6:FA:B1:18:31:B6:46:CC:F9:BA:05:95:BC:EE:D8:37:17:E1:85:9D:66:4E:04:18:E4:BF:49:01"]}},{"relation":["delegate_permission/common.handle_all_urls"],"target":{"namespace":"android_app","package_name":"it.funapp.mob.preprod","sha256_cert_fingerprints":["0B:CC:F2:94:B3:5B:53:53:21:12:A0:16:E1:3B:AB:08:B4:78:DD:61:DE:D7:8E:6C:0D:F2:5B:5C:D4:EB:75:FF"]}}]
Also, I don't get any warning after adding &d=1
to my long dynamic link
This issue has been automatically marked as stale because it has not had recent user activity. It will be closed if no further activity occurs. Thank you for your contributions.
@romreed @gaultierq @SimonErich @gidox @vvusts @Salakar
I just had the same problem and I figured out how to make it work.
I noticed that the link wasn't available right after starting the app, but on a later screen after login it was.
The problem for me was that I was checking for the initalLink in componentDidMount
but somehow the link wasn't available at that point after installing and first open. Only after I put it in componentWillReceiveProps
it correctly picked up the initalLink after installing the app.
This only happens on my login screen. On later screens, or opening the app normally (not first open) componentDidMount
works fine.
Hope that helps someone.
Hello 👋, this issue has been automatically marked as stale because it has not had activity for quite some time. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.
Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.
@Mexxerio what if you don't have props for your initial App component?
This issue should be reopened, links are not working properly.
@NirpE if you use a normal react component, then it should always have props and lifecycle methods. If you don't use a React component, then I would suggest you add one or you call the method in the first React component that gets called in your app.
I am using React.Component, but since I do not have any changing props for the root component, the method will not be called. Therefore it would force me to add extra data in order to get it triggering where I initialise the links callbacks.
@NirpE here's what I did:
componentWillReceiveProps(newProps) {
this.getInitialLink(true)
}
getInitialLink = (stop) => {
firebase.links().getInitialLink().then((url) => {
if (url) {
// do something with the link
if (Platform.OS === 'ios') {
this.timer1 = timer.setTimeout(this, 'timer1', () => {
this.setLinkListener()
}, 1000)
}
} else {
if (!stop) {
this.timer2 = timer.setTimeout(this, 'timer2', () => {
this.getInitialLink(true)
}, 2000)
}
if (Platform.OS === 'ios') {
this.setLinkListener()
}
}
})
}
setLinkListener = () => {
if (this.linkListener) {
return;
}
this.linkListener = firebase.links().onLink((url) => {
if (url) {
// do something with the link
}
})
}
If there is no link found yet I'm retrying for it after 2 seconds and also setting link listeners. I had to use different checks for ios and android. Maybe that can help you.
EDIT: I know I'm not calling the recursion in this code, and only setting the listener in ios. I was trying different things out to get the link and in android it seemed to work well without the recursion. But maybe it can bring you on the right path.
@Mexxerio is onLink
working for you in Android? I have not been able to get any triggers from that. All in all these links seems to be not so reliable. Prolly will go with Branch.io
@NirpE I think onLink
only works in ios for me as well.
@NirpE @Mexxerio I got onLink
working on Android when I added the line android:launchMode="singleTask"
into android/app/src/main/AndroidManifest.xml
:
<activity
android:name=".MainActivity"
android:launchMode="singleTask"
Make sure it's in .MainActivity
and not in .MainApplication
.
Hello guys ... is there anyway to make onLink work on android ?
@NirpE @Mexxerio I got
onLink
working on Android when I added the lineandroid:launchMode="singleTask"
intoandroid/app/src/main/AndroidManifest.xml
:<activity android:name=".MainActivity" android:launchMode="singleTask"
Make sure it's in
.MainActivity
and not in.MainApplication
.
I had android:launchMode="singleTop"
at first but changed it to singleTask
but still can't get onLink to work in android
Hey guys,
Just tried singleTask as well and for me that did the trick.
Now everything works perfectly fine.
I had SplashActivity and MainActivity and I set the singleTask to only the SplashActivity.
After adding it to MainActivity as well, everything works fine. :)
Most helpful comment
I managed to narrow it down a little.
When I use the long instead of short links, everything works perfectly fine.
It's really just the short link, that is not working.
I've also checked and added the certificate fingerprint to firebase console.
It is really weird. Any ideas?
I am using: