The Firebase Dynamic Links Unity Sample demonstrates sending and receiving Firebase Dynamic Links using the Firebase Unity SDK.
- Unity The quickstart project requires 2017.4 or higher.
- Xcode 10.3 or higher (when developing for iOS).
- Android SDK (when developing for Android).
- Register your iOS app with Firebase.
- Create a project in the
Firebase console,
and associate your iOS application.
- You should use
com.google.FirebaseUnityDynamicLinksTestApp.devas the bundle identifier when creating the Firebase iOS app in the console.- If you do not use the prescribed Bundle ID, you will later need to
update the bundle identifier in Unity as described in
Optional: Update the Project Bundle Identifierbelow.
- If you do not use the prescribed Bundle ID, you will later need to
update the bundle identifier in Unity as described in
- You should use
- Download the
GoogleService-Info.plistfile associated with your Firebase project from the console. This file identifies your iOS app to the Firebase backend, and will need to be included in the sample later. - For further details please refer to the general instructions which describes how to configure a Firebase application for iOS.
- Create a project in the
Firebase console,
and associate your iOS application.
- Download the Firebase Unity SDK and unzip it somewhere convenient.
- Open the sample project in the Unity editor.
- Select the
File > Open Projectmenu item. - Click
Open. - Navigate to the sample directory
testappin the file dialog and clickOpen.- You might be prompted to upgrade the project to your version of Unity.
Click
Confirmto upgrade the project and continue.
- You might be prompted to upgrade the project to your version of Unity.
Click
- Select the
- Open the scene
MainScene.- Navigate to
Assets/Firebase/Sample/Functionsin theProjectwindow. - Double click on
MainScenefile to open.
- Navigate to
- Import the
Firebase Dynamic Linksplugin.- Select the Assets > Import Package > Custom Package menu item.
- From the Firebase Unity SDK
downloaded previously, import
FirebaseDynamicLinks.unitypackagefrom the directory that matches the version of Unity you use:- Unity 5.x and earlier use the .NET 3.x framework, so you need to
import the
dotnet3/FirebaseDynamicLinks.unitypackagepackage . - Unity 2017.x and newer allow the use of the .NET 4.x framework. If
your project is configured to use .NET 4.x, import the
dotnet4/FirebaseDynamicLinks.unitypackagepackage.
- Unity 5.x and earlier use the .NET 3.x framework, so you need to
import the
- When the Import Unity Package window appears, click the Import button.
- Add the
GoogleService-Info.plistfile to the project.- Navigate to the
Assets/Firebase/Sample/Functionsfolder in theProjectwindow. - Drag the
GoogleService-Info.plistdownloaded from the Firebase console into the folder.- NOTE:
GoogleService-Info.plistcan be placed anywhere under theAssetsfolder.
- NOTE:
- Navigate to the
- Optional: Update the Project Bundle Identifier
- If you did not use
com.google.FirebaseUnityDynamicLinksTestApp.devas the iOS bundle ID when creating your app in the Firebase Console then you will need to update the sample's Bundle.- Select the
File > Build Settingsmenu option. - Select
iOSin thePlatformlist. - Click
Player Settings. - In the
Settings for iOSpanel scroll down toBundle Identifierand update the value to theiOS bundle IDyou provided when you registered your app with Firebase.
- Select the
- If you did not use
- Copy the dynamic links domain URI prefix for your project under the Dynamic
Links tab of the Firebase console
e.g xyz.app.goo.gl and assign it to the string DomainUriPrefix on the
UIHandler object in the MainScene.
- Optional: If you want to use a custom Dynamic Links domain, follow these instructions to set up the domain in Firebase console and in your project's Info.plist.
- Build for iOS
- Select the
File > Build Settingsmenu option. - Select
iOSin thePlatformlist. - Click
Switch Platformto selectiOSas the target platform. - Wait for the spinner (compiling) icon to stop in the bottom right corner of the Unity status bar.
- Click
Build and Run.
- Select the
- Configure the iOS project capabilities to send invites and receive links.
- Enable the Keychain Sharing capability on iOS 10 or above (required by Google Sign-In to send invites). You can enable this capability on your project in Xcode 8 by going to your project's settings, Capabilities, and turning on Keychain Sharing.
- Copy the domain URI prefix for your project under the Dynamic Links tab of
the Firebase console Then, in your
project's Capabilities tab:
- Enable the Associated Domains capability.
- Add applinks:YOUR_DYNAMIC_LINKS_DOMAIN For example "applinks:xyz.app.goo.gl".
- See the Using the Sample section below.
- Register your Android app with Firebase.
- Create a project in the
Firebase console,
and attach your Android app to it.
- You should use
com.google.FirebaseUnityDynamicLinksTestApp.devas theAndroid package namewhile you're testing.- If you do not use the prescribed package name, you will need to update
the bundle identifier as described in
Optional: Update the Project Bundle Identifierbelow.
- If you do not use the prescribed package name, you will need to update
the bundle identifier as described in
- Android apps must be signed by a key, and the key's signature must
be registered to your project in the Firebase Console. To
generate a SHA1,
first you will need to set the keystore in the Unity project.
- Locate the
Publishing SettingsunderPlayer Settings. - Select an existing keystore, or create a new keystore using the toggle.
- Select an existing key, or create a new key using "Create a new key".
- After setting the keystore and key, you can generate a SHA1 by
running this command:
keytool -list -v -keystore <path_to_keystore> -alias <key_name> - Copy the SHA1 digest string into your clipboard.
- Navigate to your Android App in your firebase console.
- From the main console view, click on your Android App at the top, then click the gear to open the settings page.
- Scroll down to your apps at the bottom of the page and click on
Add Fingerprint. - Paste the SHA1 digest of your key into the form. The SHA1 box will illuminate if the string is valid. If it's not valid, check that you have copied the entire SHA1 digest string.
- Locate the
- You should use
- Download the
google-services.jsonfile associated with your Firebase project from the console. This file identifies your Android app to the Firebase backend, and will need to be included in the sample later.- For further details please refer to the general instructions which describes how to configure a Firebase application for Android.
- Create a project in the
Firebase console,
and attach your Android app to it.
- Download the Firebase Unity SDK and unzip it somewhere convenient.
- Open the sample project in the Unity editor.
- Select the
File > Open Projectmenu item. - Click
Open.- You might be prompted to upgrade the project to your version of Unity.
Click
Confirmto upgrade the project and continue.
- You might be prompted to upgrade the project to your version of Unity.
Click
- Navigate to the sample directory
testappin the file dialog and clickOpen.
- Select the
- Open the scene
MainScene.- Navigate to
Assets/Firebase/Sample/Functionsin theProjectwindow. - Double click on
MainScenefile to open.
- Navigate to
- Import the
Firebase Dynamic Linksplugin.- Select the Assets > Import Package > Custom Package menu item.
- From the Firebase Unity SDK
downloaded previously, import
FirebaseDynamicLinks.unitypackagefrom the directory that matches the version of Unity you use:- Unity 5.x and earlier use the .NET 3.x framework, so you need to
import the
dotnet3/FirebaseDynamicLinks.unitypackagepackage . - Unity 2017.x and newer allow the use of the .NET 4.x framework. If
your project is configured to use .NET 4.x, import the
dotnet4/FirebaseDynamicLinks.unitypackagepackage.
- Unity 5.x and earlier use the .NET 3.x framework, so you need to
import the
- When the Import Unity Package window appears, click the Import button.
- Add the
google-services.jsonfile to the project.- Navigate to the
Assets/Firebase/Sample/Functionsfolder in theProjectwindow. - Drag the
google-services.jsondownloaded from the Firebase console into the folder.- NOTE:
google-services.jsoncan be placed anywhere under theAssetsfolder.
- NOTE:
- Navigate to the
- Optional: Update the Project Bundle Identifier
- If you did not use
com.google.FirebaseUnityDynamicLinksTestApp.devas theAndroid package namewhen you created your app in the Firebase Console, you will need to update the sample's Bundle Identifier.- Select the
File > Build Settingsmenu option. - Select
Androidin thePlatformlist. - Click
Player Settings - In the
Settings for Androidpanel scroll down toBundle Identifierand update the value to the Android package name you provided when you registered your app with Firebase.
- Select the
- If you did not use
- Copy the dynamic links domain URI prefix for your project under the Dynamic
Links tab of the Firebase console
e.g xyz.app.goo.gl and assign it to the string DomainUriPrefix on the
UIHandler object in the MainScene.
- Optional: If you want to use a custom Dynamic Links domain, follow these instructions to set up the domain in Firebase console.
- Build for Android
- Select the
File > Build Settingsmenu option. - Select
Androidin thePlatformlist. - Click
Switch Platformto selectAndroidas the target platform. - Wait for the spinner (compiling) icon to stop in the bottom right corner of the Unity status bar.
- Click
Build and Run.
- Select the
- See the Using the Sample section below.
- Receiving a link
- When you first run the app, it will check for an incoming dynamic link and report whether it was able to fetch a link.
- To simulate receiving a dynamic link, you can send yourself an email, uninstall the test app, then click the link in your email.
- This would normally send you to the Play Store or App Store to download the app. Because this is a test app, it will link to a nonexistent store page.
- After clicking the dynamic link, re-install and run the app on your device or emulator, and see the dynamic link fetched on the receiving side.
- Creating a link
- Clicking the Display Long Link button creates and displays a long dynamic link.
- Clicking the Create Short Link button creates and displays a short link by contacting the link shortening service.
- Clicking the Create Unguessable Short Link button creates and displays an unguessable short link.
- When upgrading to a new Firebase release: import the new firebase unity package through Assets > Import Package > Custom Package as above. After the import is complete you may need to run the Assets > Play Services Resolver for the changes to be reflected in the editor. If issues persist, delete the plugin and install it again.
- Android: After exiting the editor and returning you will need to reconfigure the Project Keystore in Player Settings > Publishing Settings. Select your Custom Keystore from the dropdown list and enter its password. Then, select your Project Key alias and enter your key's password. enabled in your project, you'll see compile errors from some types in the
- Please see the Known Issues section of the Unity Setup Guide](https://firebase.google.com/docs/unity/setup) for other troubleshooting topics.
https://firebase.google.com/support/
Copyright 2016 Google, Inc.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.