Official documentation was available, and I think it's okay if you follow the basics, but it's a bit clogged. There was also a point, so I will summarize it with a memo.
Log in from Firebase console. Check the API KEY of Firebase. Then move to the project settings. Enter the following values for iOS and Android from "Add App" to add. The following are all required.
iOS
App ID Prefix is used because the apple-app-site-association for Universal Link is generated behind the scenes.
Android
I will add it appropriately.
If you get any error here, you made a mistake in adding the app.
When you add a link, the following domain should be displayed in the upper left of the link list table, so make a note of it (important).
https://xxx.app.goo.gl/
import requests
url = "https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=FIREBASE_API_KEY"
data = {
"dynamicLinkInfo": {
"dynamicLinkDomain": "xxx.app.goo.gl",
"link": "http://example.com/",
"androidInfo": {
"androidPackageName": "com.example.AndroidApp"
},
"iosInfo": {
"iosBundleId": "com.example.iOSApp"
}
}
}
result = requests.post(url, json=data)
If result.ok
is true, you are successful.
If successful, you'll find the URL in result.json ()
.
You can't find the domain mentioned above without adding one Dynamic Links on the Firebase console (maybe you just missed it).
So, at first, the domain of dynamicLinkDomain
in the above code example is [firebase project name] .app.goo.gl
? When I tried it, I got the following error
{
'error': {
'code': 400,
'message': 'Request contains an invalid argument.',
'status': 'INVALID_ARGUMENT'
}
}
I didn't know what was wrong and I was exhausted.
Well, other people may not get stuck, but I was inadvertently worried. I wrote it in the hope that it would help someone.
that's all.
Recommended Posts