[go: nahoru, domu]

Skip to content

Commit

Permalink
Integrate Latest @ 286210488
Browse files Browse the repository at this point in the history
CL: 286210488
  • Loading branch information
Stewart Miles committed Dec 19, 2019
1 parent 8da4d26 commit d97daa5
Show file tree
Hide file tree
Showing 20 changed files with 779 additions and 266 deletions.
5 changes: 3 additions & 2 deletions analytics/testapp/ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ PlayerSettings:
disableDepthAndStencilBuffers: 0
defaultIsFullScreen: 1
defaultIsNativeResolution: 1
runInBackground: 0
runInBackground: 1
captureSingleScreen: 0
Override IPod Music: 0
Prepare IOS For Recording: 0
Expand Down Expand Up @@ -161,7 +161,8 @@ PlayerSettings:
iOSLaunchScreeniPadSize: 100
iOSLaunchScreeniPadCustomXibPath:
iOSDeviceRequirements: []
iOSURLSchemes: []
iOSURLSchemes:
- firebase-game-loop
appleDeveloperTeamID:
iOSManualSigningProvisioningProfileID:
tvOSManualSigningProvisioningProfileID:
Expand Down
85 changes: 60 additions & 25 deletions analytics/testapp/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ with the
[Firebase console](https://firebase.google.com/console/),
and associate your iOS application.
- You should use `com.google.firebase.unity.analytics.testapp` as the
package name while you're testing.
- If you do not use the prescribed package name you will need to update
the bundle identifier as described in the
iOS bundle ID 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 Identifier` below.
- Download the `GoogleService-Info.plist` file associated with your
Firebase project from the console.
Expand All @@ -40,12 +40,14 @@ with the
and unzip it somewhere convenient.
- Open the sample project in the Unity editor.
- Select the `File > Open Project` menu item.
- Click `Open`.
- If Unity Hub appears, click `Add`. Otherwise click `Open`.
- Navigate to the sample directory `testapp` in the file dialog and click
`Open`.
- You might be prompted to upgrade the project to your version of Unity.
Click `Confirm` to upgrade the project and continue.
- Open the scene `MainScene`.
- Navigate to `Assets/Firebase/Sample/Analytics` in the `Project` window.
- Double click on `MainScene` file to open.
- Double click on the `MainScene` file to open it.
- Import the `Firebase Analytics` plugin.
- Select the **Assets > Import Package > Custom Package** menu item.
- From the [Firebase Unity SDK](https://firebase.google.com/download/unity)
Expand All @@ -67,13 +69,13 @@ with the
`Assets` folder.
- Optional: Update the Project Bundle Identifier
- If you did not use `com.google.firebase.unity.analytics.testapp`
as the project package name you will need to update the sample's Bundle
Identifier.
as the iOS bundle ID when creating your app in the Firebase
Console, you will need to update the sample's Bundle Identifier.
- Select the `File > Build Settings` menu option.
- Select `iOS` in the `Platform` list.
- Click `Player Settings`
- In the `Player Settings` panel scroll down to `Bundle Identifier`
and update the value to the package name you provided when you
- In the `Settings for iOS` panel scroll down to `Bundle Identifier`
and update the value to the `iOS bundle ID` you provided when you
registered your app with Firebase.
- Build for iOS
- Select the `File > Build Settings` menu option.
Expand All @@ -92,21 +94,32 @@ with the
[Firebase console](https://firebase.google.com/console/),
and attach your Android app to it.
- You should use `com.google.firebase.unity.analytics.testapp` as the
package name while you're testing.
- If you do not use the prescribed package name you will need to update
the bundle identifier as described in the
Android package name while 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 Identifier` below.

- To [generate a SHA1](https://developers.google.com/android/guides/client-auth),
- 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](https://developers.google.com/android/guides/client-auth),
first you will need to set the keystore in the Unity project.
- Locate the `Publishing Settings` under `Player Settings`.
- Select an existing keystore, or create a new keystore using the toggle.
- 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 -exportcert -list -v -alias <key_name> -keystore <path_to_keystore>
```
- 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 and
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.
- Download the `google-services.json` file associated with your
Firebase project from the console.
This file identifies your Android app to the Firebase backend, and will
Expand All @@ -119,12 +132,14 @@ with the
and unzip it somewhere convenient.
- Open the sample project in the Unity editor.
- Select the `File > Open Project` menu item.
- Click `Open`.
- If Unity Hub appears, click `Add`. Otherwise click `Open`.
- Navigate to the sample directory `testapp` in the file dialog and click
`Open`.
- You might be prompted to upgrade the project to your version of Unity.
Click `Confirm` to upgrade the project and continue.
- Open the scene `MainScene`.
- Navigate to `Assets/Firebase/Sample/Analytics` in the `Project` window.
- Double click on `MainScene` file to open.
- Double click on the `MainScene` file to open it.
- Import the `Firebase Analytics` plugin.
- Select the **Assets > Import Package > Custom Package** menu item.
- From the [Firebase Unity SDK](https://firebase.google.com/download/unity)
Expand All @@ -146,12 +161,12 @@ with the
folder.
- Optional: Update the Project Bundle Identifier
- If you did not use `com.google.firebase.unity.analytics.testapp`
as the project package name you will need to update the sample's Bundle
Identifier.
as the `Android package name` when you created your app in the Firebase
Console, you will need to update the sample's Bundle Identifier.
- Select the `File > Build Settings` menu option.
- Select `Android` in the `Platform` list.
- Click `Player Settings`
- In the `Player Settings` panel scroll down to `Bundle Identifier`
- In the `Settings for Android` panel scroll down to `Bundle Identifier`
and update the value to the package name you provided when you
registered your app with Firebase.
- Build for Android
Expand Down Expand Up @@ -185,6 +200,26 @@ After around 5 hours, data should be visible under the *Analytics* tab in
the [Firebase Console](https://firebase.google.com/console/)).


## Troubleshooting

- 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](https://firebase.google.com/docs/unity/setup#known-issues)
section of the
Unity Setup Guide](https://firebase.google.com/docs/unity/setup) for other
troubleshooting topics.


## Support

[https://firebase.google.com/support/](https://firebase.google.com/support/)
Expand Down
173 changes: 172 additions & 1 deletion auth/testapp/Assets/Firebase/Sample/Auth/UIHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ public class UIHandler : MonoBehaviour {
protected string displayName = "";
protected string phoneNumber = "";
protected string receivedCode = "";
protected string scope1 = "";
protected string scope2 = "";
protected string customParameterKey1 = "";
protected string customParameterValue1 = "";
protected string customParameterKey2 = "";
protected string customParameterValue2 = "";
// Whether to sign in / link or reauthentication *and* fetch user profile data.
protected bool signInAndFetchProfile = false;
// Flag set when a token is being fetched. This is used to avoid printing the token
Expand Down Expand Up @@ -224,7 +230,7 @@ public class UIHandler : MonoBehaviour {
user = senderAuth.CurrentUser;
userByAuth[senderAuth.App.Name] = user;
if (signedIn) {
DebugLog("Signed in " + user.UserId);
DebugLog("AuthStateChanged Signed in " + user.UserId);
displayName = user.DisplayName ?? "";
DisplayDetailedUserInfo(user, 1);
}
Expand Down Expand Up @@ -546,6 +552,100 @@ public class UIHandler : MonoBehaviour {
});
}

protected Firebase.Auth.FederatedOAuthProvider BuildFederatedOAuthProvider(string providerId) {
Firebase.Auth.FederatedOAuthProviderData data = new Firebase.Auth.FederatedOAuthProviderData();
data.ProviderId = providerId;
List<string> scopes = new List<string>();
if(scope1 != "" ) {
scopes.Add(scope1);
}
if(scope2 != "" ) {
scopes.Add(scope2);
}
data.Scopes = scopes;

data.CustomParameters = new Dictionary<string, string>();
if(customParameterKey1 != "" && customParameterValue1 != "") {
data.CustomParameters.Add(customParameterKey1, customParameterValue1);
}
if(customParameterKey2 != "" && customParameterValue2 != "") {
data.CustomParameters.Add(customParameterKey2, customParameterValue2);
}

return new Firebase.Auth.FederatedOAuthProvider(data);
}
protected void SignInWithProvider(string providerId) {
Firebase.Auth.FederatedOAuthProvider provider = BuildFederatedOAuthProvider(providerId);
auth.SignInWithProviderAsync(provider).ContinueWithOnMainThread(signin_task => {
if (LogTaskCompletion(signin_task, "SignInWithProvider")) {
DebugLog("SignInWithProviderTask Completed:" + signin_task.IsCompleted);
}
if(signin_task.Exception != null) {
DebugLog("SignInWithProviderTask - Exception: " + signin_task.Exception.Message);
return;
}
DisplaySignInResult(signin_task.Result, 1);
});
}

protected void ReauthenticateWithProvider(string providerId) {
if(auth.CurrentUser == null) {
DebugLog("Login with user before re-authenticating");
return;
}

Firebase.Auth.FederatedOAuthProvider provider = BuildFederatedOAuthProvider(providerId);

auth.CurrentUser.ReauthenticateWithProviderAsync(provider).ContinueWithOnMainThread(task => {
if (LogTaskCompletion(task, "ReauthenticateWithProvider")) {
DebugLog("ReauthenticateWithProvider Completed:" + task.IsCompleted);
}
if(task.Exception != null) {
Debug.Log("ReauthenticateWithProviderTask - Exception: " + task.Exception.Message);
return;
}
DisplaySignInResult(task.Result, 1);
});
}

protected void LinkWithProvider(string providerId) {
if(auth.CurrentUser == null) {
DebugLog("Login with user before linking.");
return;
}

Firebase.Auth.FederatedOAuthProvider provider = BuildFederatedOAuthProvider(providerId);
auth.CurrentUser.LinkWithProviderAsync(provider).ContinueWithOnMainThread(task => {
if (LogTaskCompletion(task, "LinkWithProvider")) {
DebugLog("LinkWithProvider Completed:" + task.IsCompleted);
}
if(task.Exception != null) {
Debug.Log("LinkWithProvider - Exception: " + task.Exception.Message);
return;
}
DisplaySignInResult(task.Result, 1);
});
}

protected void UnlinkUser(string providerId) {
if(auth.CurrentUser == null) {
DebugLog("Login with user before un-linking.");
return;
}

if (auth.CurrentUser != null) {
DebugLog("Attempting to ulink user from provider: " + providerId);
DisableUI();
auth.CurrentUser.UnlinkAsync(providerId).ContinueWithOnMainThread( task => {
EnableUI();
DebugLog("Unlink Complete");
});
} else {
DebugLog("Sign-in before unlinking user.");
}
}

// Begin authentication with the phone number.
protected void VerifyPhoneNumber() {
var phoneAuthProvider = Firebase.Auth.PhoneAuthProvider.GetInstance(auth);
Expand Down Expand Up @@ -731,6 +831,77 @@ public class UIHandler : MonoBehaviour {
otherAuth.App.Name))) {
SwapAuthFocus();
}

GUILayout.Space(20);

GUILayout.BeginHorizontal();
GUILayout.Label("Phone-Only OAuth2:", GUILayout.Width(Screen.width * 0.4f));
GUILayout.EndHorizontal();

GUILayout.BeginHorizontal();
GUILayout.Label("scope 1:", GUILayout.Width(Screen.width * 0.20f));
scope1 = GUILayout.TextField(scope1, GUILayout.Width(Screen.width * 0.5f));
GUILayout.EndHorizontal();

GUILayout.Space(20);

GUILayout.BeginHorizontal();
GUILayout.Label("scope 2:", GUILayout.Width(Screen.width * 0.20f));
scope2 = GUILayout.TextField(scope2, GUILayout.Width(Screen.width * 0.5f));
GUILayout.EndHorizontal();

GUILayout.Space(20);

GUILayout.BeginHorizontal();
GUILayout.Label("customParam Key1:", GUILayout.Width(Screen.width * 0.20f));
customParameterKey1 = GUILayout.TextField(customParameterKey1, GUILayout.Width(Screen.width * 0.5f));
GUILayout.EndHorizontal();

GUILayout.Space(20);

GUILayout.BeginHorizontal();
GUILayout.Label("customParam Value1:", GUILayout.Width(Screen.width * 0.20f));
customParameterValue1 = GUILayout.TextField(customParameterValue1, GUILayout.Width(Screen.width * 0.25f));
GUILayout.EndHorizontal();

GUILayout.BeginHorizontal();
GUILayout.Label("customParam Key2:", GUILayout.Width(Screen.width * 0.20f));
customParameterKey2 = GUILayout.TextField(customParameterKey2, GUILayout.Width(Screen.width * 0.5f));
GUILayout.EndHorizontal();

GUILayout.Space(20);

GUILayout.BeginHorizontal();
GUILayout.Label("customParam Value2:", GUILayout.Width(Screen.width * 0.20f));
customParameterValue2 = GUILayout.TextField(customParameterValue2, GUILayout.Width(Screen.width * 0.5f));
GUILayout.EndHorizontal();

GUILayout.Space(20);
if (GUILayout.Button("SignInWith | Microsoft")) {
SignInWithProvider(Firebase.Auth.MicrosoftAuthProvider.ProviderId);
}
if (GUILayout.Button("SignInWith | Yahoo")) {
SignInWithProvider(Firebase.Auth.YahooAuthProvider.ProviderId);
}
if (GUILayout.Button("ReauthWith | Microsoft")) {
ReauthenticateWithProvider(Firebase.Auth.MicrosoftAuthProvider.ProviderId);
}
if (GUILayout.Button("ReauthWith | Yahoo")) {
ReauthenticateWithProvider(Firebase.Auth.YahooAuthProvider.ProviderId);
}
if (GUILayout.Button("LinkWith | Microsoft")) {
LinkWithProvider(Firebase.Auth.MicrosoftAuthProvider.ProviderId);
}
if (GUILayout.Button("LinkWith | Yahoo")) {
LinkWithProvider(Firebase.Auth.YahooAuthProvider.ProviderId);
}
if (GUILayout.Button("Unlink User | Microsoft")) {
UnlinkUser(Firebase.Auth.MicrosoftAuthProvider.ProviderId);
}
if (GUILayout.Button("Unlink User | Yahoo")) {
UnlinkUser(Firebase.Auth.YahooAuthProvider.ProviderId);
}

GUIDisplayCustomControls();
GUILayout.EndVertical();
GUILayout.EndScrollView();
Expand Down
5 changes: 3 additions & 2 deletions auth/testapp/ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ PlayerSettings:
disableDepthAndStencilBuffers: 0
defaultIsFullScreen: 0
defaultIsNativeResolution: 1
runInBackground: 0
runInBackground: 1
captureSingleScreen: 0
Override IPod Music: 0
Prepare IOS For Recording: 0
Expand Down Expand Up @@ -161,7 +161,8 @@ PlayerSettings:
iOSLaunchScreeniPadSize: 100
iOSLaunchScreeniPadCustomXibPath:
iOSDeviceRequirements: []
iOSURLSchemes: []
iOSURLSchemes:
- firebase-game-loop
appleDeveloperTeamID:
iOSManualSigningProvisioningProfileID:
tvOSManualSigningProvisioningProfileID:
Expand Down
Loading

0 comments on commit d97daa5

Please sign in to comment.