I have an Expo/React Native app and I'm trying to implement Firebase Dynamic Links so that I can connect two users. So, user A would provide a dynamic link to user B. If user B doesn't have the app already installed, the link would send the user to App Store or Google Play for it to be installed. Once the installation is completed, the app would open up and retrieve user A's ID. If user B already has the app installed, the dynamic link would simply open the app and retrieve user A's ID.
Here's my question: if I define a dynamic link through the Firebase console, can I add parameters to it in my app? In other words, simply use the dynamic link on the console and add user A's ID to it.
Or if I need to send parameters that will depend on the user, do I need to generate them through the REST API?
I'm currently trying the REST API but keep getting 401
error. I simply make a POST
call with the following request object to the https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key={MyWebAPIKey}
. And here's my request object:
{
"dynamicLinkInfo": {
"domainUriPrefix": "https://dl.mydomain.com/link",
"link": "https://dl.mydomain.com/link?id=12345",
"androidInfo": {
"androidPackageName": "com.my-domain.myapp"
},
"iosInfo": {
"iosBundleId": "com.my-domain.myapp"
}
}
My https://dl.mydomain.com
is hosted by Firebase and is used only for dynamic linking purposes and when I go to the Dynamic Links console, it shows
https://dl.mydomain.com/link
as my URL prefix.
So, I'm trying to understand:
- If I'll simply add a user ID as a parameter, can I use the dynamic link I create through the console or do I need to generate a dynamic link programmatically -- in my case through the REST API?
- If I need to do it through the REST API, what am I doing wrong in my code?
PS: Interestingly, when I try the POST
call to Shortlinks API using Postman, it actually works and gives me a shortlink. When I try the same thing in my Expo app, I get a 401
error.