diff --git a/Assets/Editor/XCodePostProcessBuild.cs b/Assets/Editor/XCodePostProcessBuild.cs
index 6f947a33..42c27f86 100644
--- a/Assets/Editor/XCodePostProcessBuild.cs
+++ b/Assets/Editor/XCodePostProcessBuild.cs
@@ -5,6 +5,7 @@ using System.IO;
using UnityEngine;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
+using System;
#endif
@@ -15,7 +16,7 @@ public static class XCodePostProcessBuild
"Security.framework","WebKit.framework", "CoreGraphics.framework"
};
- [PostProcessBuild(1)]
+ [PostProcessBuild(11)]
public static void OnPostprocessBuild(BuildTarget buildTarget, string pathToBuiltProject)
{
if (BuildTarget.iOS != buildTarget)
@@ -24,10 +25,27 @@ public static class XCodePostProcessBuild
}
string projectPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
SetFrameworksAndBuildSettings(projectPath);
+ AddGooglePlist(pathToBuiltProject,projectPath);
SetInfoList(pathToBuiltProject, "com.ZhiXingPai.PowerFun", "wxe3573a84e7e29902");
SetAssociatedDomains(projectPath, "wx.powerfun.com.cn");
Assets.NativeLocale.AddLocalizedStringsIOS(pathToBuiltProject, Path.Combine(Application.dataPath, "Editor/Locale"));
}
+
+ private static void AddGooglePlist(string pathToBuiltProject,string path)
+ {
+ PBXProject proj = new PBXProject();
+ proj.ReadFromString(File.ReadAllText(path));
+ // This is the Xcode target in the generated project
+ string target = proj.GetUnityMainTargetGuid();
+
+ // Copy plist from the project folder to the build folder
+ FileUtil.CopyFileOrDirectory("Assets/Plugins/iOS/GoogleService-Info.plist", pathToBuiltProject + "/GoogleService-Info.plist");
+ proj.AddFileToBuild(target, proj.AddFile("GoogleService-Info.plist", "GoogleService-Info.plist"));
+
+ // Write PBXProject object back to the file
+ proj.WriteToFile(path);
+ }
+
private static void SetFrameworksAndBuildSettings(string path)
{
PBXProject proj = new PBXProject();
@@ -38,6 +56,7 @@ public static class XCodePostProcessBuild
proj.AddBuildProperty(target, "Other Linker Flags", "-Objc -all_load");
proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
+
//根据微信SDK文档的要求,加入相关的Frameworks
for (int i = 0; i < csAddFrameworks.Length; ++i)
{
@@ -48,7 +67,11 @@ public static class XCodePostProcessBuild
//苹果登录配置项
//proj.AddCapability(target, PBXCapabilityType.SignInWithApple);
proj.AddFrameworkToProject(proj.GetUnityFrameworkTargetGuid(), "AuthenticationServices.framework", false);
-
+ //移除无用配置项
+ proj.RemoveFrameworkFromProject(proj.GetUnityFrameworkTargetGuid(), "Chromium Embedded Framework.framework");
+ proj.SetBuildProperty(proj.ProjectGuid(), "ENABLE_BITCODE", "NO");
+ proj.SetBuildProperty(proj.ProjectGuid(), "CLANG_ENABLE_MODULES", "YES");
+
File.WriteAllText(path, proj.WriteToString());
}
@@ -65,12 +88,19 @@ public static class XCodePostProcessBuild
dict.SetString("CFBundleURLName", wxUrlName);
PlistElementArray urlSchemes = dict.CreateArray("CFBundleURLSchemes");
urlSchemes.AddString(wxScheme);
+
PlistElementDict dictMine = urlArray.AddDict();
dictMine.SetString("CFBundleTypeRole", "Editor");
dictMine.SetString("CFBundleURLName", "powerfunx");
PlistElementArray urlSchemesMine = dictMine.CreateArray("CFBundleURLSchemes");
urlSchemesMine.AddString("powerfunx");
+ PlistElementDict dictGG = urlArray.AddDict();
+ dictGG.SetString("CFBundleTypeRole", "Editor");
+ dictGG.SetString("CFBundleURLName", "google");
+ PlistElementArray urlSchemesGG = dictGG.CreateArray("CFBundleURLSchemes");
+ urlSchemesGG.AddString("com.googleusercontent.apps.492440200766-spo9287smn7epmlarib2pek9kficsq86");
+
// 在 “info”标签栏的“LSApplicationQueriesSchemes“添加weixin wechat和weixinULAPI
PlistElementArray wxArray = plist.root.CreateArray("LSApplicationQueriesSchemes");
wxArray.AddString("weixin");
diff --git a/Assets/FacebookSDK/Plugins/Editor/Dependencies.xml b/Assets/FacebookSDK/Plugins/Editor/Dependencies.xml
index 0d248b3f..6d05c484 100644
--- a/Assets/FacebookSDK/Plugins/Editor/Dependencies.xml
+++ b/Assets/FacebookSDK/Plugins/Editor/Dependencies.xml
@@ -14,5 +14,7 @@
+
+
diff --git a/Assets/PlayServicesResolver/Editor/Google.IOSResolver_v1.2.135.0.dll b/Assets/PlayServicesResolver/Editor/Google.IOSResolver_v1.2.135.0.dll
index a9b0b5ae..5877d86d 100644
Binary files a/Assets/PlayServicesResolver/Editor/Google.IOSResolver_v1.2.135.0.dll and b/Assets/PlayServicesResolver/Editor/Google.IOSResolver_v1.2.135.0.dll differ
diff --git a/Assets/Plugins/iOS/GoogleService-Info.plist b/Assets/Plugins/iOS/GoogleService-Info.plist
new file mode 100644
index 00000000..f23cc195
--- /dev/null
+++ b/Assets/Plugins/iOS/GoogleService-Info.plist
@@ -0,0 +1,36 @@
+
+
+
+
+ CLIENT_ID
+ 492440200766-spo9287smn7epmlarib2pek9kficsq86.apps.googleusercontent.com
+ REVERSED_CLIENT_ID
+ com.googleusercontent.apps.492440200766-spo9287smn7epmlarib2pek9kficsq86
+ ANDROID_CLIENT_ID
+ 492440200766-0fqskhb6ebtag1hlqpo7fo93cuaarsl6.apps.googleusercontent.com
+ API_KEY
+ AIzaSyCapHL0ck1BuzfS2Drbup4VRO0jf_9fp_U
+ GCM_SENDER_ID
+ 492440200766
+ PLIST_VERSION
+ 1
+ BUNDLE_ID
+ com.ZhiXingPai.PowerFun
+ PROJECT_ID
+ powerfun-c1019
+ STORAGE_BUCKET
+ powerfun-c1019.appspot.com
+ IS_ADS_ENABLED
+
+ IS_ANALYTICS_ENABLED
+
+ IS_APPINVITE_ENABLED
+
+ IS_GCM_ENABLED
+
+ IS_SIGNIN_ENABLED
+
+ GOOGLE_APP_ID
+ 1:492440200766:ios:87037cb11ad738c0e4d36f
+
+
\ No newline at end of file
diff --git a/Assets/ExternalDependencyManager/Editor/1.2.168.meta b/Assets/Plugins/iOS/GoogleService-Info.plist.meta
similarity index 67%
rename from Assets/ExternalDependencyManager/Editor/1.2.168.meta
rename to Assets/Plugins/iOS/GoogleService-Info.plist.meta
index e7304b70..02fac433 100644
--- a/Assets/ExternalDependencyManager/Editor/1.2.168.meta
+++ b/Assets/Plugins/iOS/GoogleService-Info.plist.meta
@@ -1,6 +1,5 @@
fileFormatVersion: 2
-guid: ccd268c2c2c420741bbf29cb19e4aada
-folderAsset: yes
+guid: 8f722ab35ffa939418fdbda7f0793bc7
DefaultImporter:
externalObjects: {}
userData:
diff --git a/Assets/Plugins/iOS/IOSWechatController.m b/Assets/Plugins/iOS/IOSWechatController.m
index 119a1d8b..1c1d6bae 100644
--- a/Assets/Plugins/iOS/IOSWechatController.m
+++ b/Assets/Plugins/iOS/IOSWechatController.m
@@ -14,6 +14,8 @@
#import
#import
#import
+@import Firebase;
+@import GoogleSignIn;
extern void UnitySendMessage(const char *,const char *,const char *);
@interface IOSWechatController : UnityAppController
@@ -49,6 +51,12 @@ options:(NSDictionary *)options
return [WXApi handleOpenURL:url delegate:self];
}
+- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ //google登录
+ [FIRApp configure];
+}
+
- (void)onResp:(BaseResp *)resp
{
NSLog(@"47");
diff --git a/Assets/Plugins/iOS/Podfile b/Assets/Plugins/iOS/Podfile
new file mode 100644
index 00000000..218fb1be
--- /dev/null
+++ b/Assets/Plugins/iOS/Podfile
@@ -0,0 +1,15 @@
+source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
+platform :ios, '10.0'
+
+target 'UnityFramework' do
+ pod 'FBSDKCoreKit', '~> 11.0'
+ pod 'FBSDKCoreKit_Basics', '~> 11.0'
+ pod 'FBSDKGamingServicesKit', '~> 11.0'
+ pod 'FBSDKLoginKit', '~> 11.0'
+ pod 'FBSDKShareKit', '~> 11.0'
+ pod 'Firebase/Auth'
+ pod 'GoogleSignIn'
+end
+target 'Unity-iPhone' do
+end
+use_frameworks!
diff --git a/Assets/Plugins/iOS/Podfile.meta b/Assets/Plugins/iOS/Podfile.meta
new file mode 100644
index 00000000..c083b5ca
--- /dev/null
+++ b/Assets/Plugins/iOS/Podfile.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: f168de8faf0b96c4f8bf9708edb05015
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Plugins/iOS/SignWithApple.h b/Assets/Plugins/iOS/SignWithApple.h
index ddc284c6..0c9fb01f 100644
--- a/Assets/Plugins/iOS/SignWithApple.h
+++ b/Assets/Plugins/iOS/SignWithApple.h
@@ -1,4 +1,7 @@
-# import
+#import
+@import Firebase;
+@import GoogleSignIn;
+#import "UnityAppController.h"
@interface AppleAuth: NSObject
- (void)authorizationAppleID;
diff --git a/Assets/Plugins/iOS/SignWithApple.m b/Assets/Plugins/iOS/SignWithApple.m
index 8481e6ed..15f2a76d 100644
--- a/Assets/Plugins/iOS/SignWithApple.m
+++ b/Assets/Plugins/iOS/SignWithApple.m
@@ -40,7 +40,27 @@ static AppleAuth * _appleAuth;
[authorizationController performRequests];
}
}
+- (void) authorizationGoogleID{
+ NSLog(@"cypgoogle");
+ GIDConfiguration *config = [[GIDConfiguration alloc] initWithClientID:[FIRApp defaultApp].options.clientID];
+ __weak __auto_type weakSelf = self;
+ UnityAppController * root = (UnityAppController*)[UIApplication sharedApplication].delegate;
+ [GIDSignIn.sharedInstance signInWithConfiguration:config presentingViewController:root.rootViewController callback:^(GIDGoogleUser * _Nullable user, NSError * _Nullable error) {
+ __auto_type strongSelf = weakSelf;
+ if (strongSelf == nil) { return; }
+ if (error == nil) {
+ GIDAuthentication *authentication = user.authentication;
+ UnitySendMessage("LoginPanel", "OnMobileGoogleLoginResp", [NSString stringWithFormat:@"true;%@|%@",user.userID,authentication.idToken ].UTF8String);
+ // FIRAuthCredential *credential =
+ // [FIRGoogleAuthProvider credentialWithIDToken:authentication.idToken
+ // accessToken:authentication.accessToken];
+ // ...
+ } else {
+ // ...
+ }
+ }];
+}
#pragma mark- ASAuthorizationControllerDelegate
// 授权成功
- (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithAuthorization:(ASAuthorization *)authorization API_AVAILABLE(ios(13.0)) {
@@ -121,4 +141,9 @@ static AppleAuth * _appleAuth;
void authorizationAppleID(){
AppleAuth * a = [AppleAuth instance];
[a authorizationAppleID];
+}
+
+void authorizationGoogleID(){
+ AppleAuth * a = [AppleAuth instance];
+ [a authorizationGoogleID];
}
\ No newline at end of file
diff --git a/Assets/Scripts/App.cs b/Assets/Scripts/App.cs
index a9a021f8..b718fc82 100644
--- a/Assets/Scripts/App.cs
+++ b/Assets/Scripts/App.cs
@@ -19,7 +19,7 @@ public delegate void ChangeLanguageDelegate();
public static class App
{
- public static string Host = "http://192.168.0.101:5084/";
+ public static string Host = "http://192.168.0.101:5087/";
public static string AppVersion = Application.version;
diff --git a/Assets/Scripts/Mobile/LoginControllerMobile.cs b/Assets/Scripts/Mobile/LoginControllerMobile.cs
index 8cd531d4..e996aa6c 100644
--- a/Assets/Scripts/Mobile/LoginControllerMobile.cs
+++ b/Assets/Scripts/Mobile/LoginControllerMobile.cs
@@ -70,6 +70,8 @@ public class LoginControllerMobile : MonoBehaviour, INativeOnMobileWxLoginResp
{
#if UNITY_EDITOR
OnMobileGoogleLoginResp("true;105370187704207825625|eyJhbGciOiJSUzI1NiIsImtpZCI6ImNhMDA2MjBjNWFhN2JlOGNkMDNhNmYzYzY4NDA2ZTQ1ZTkzYjNjYWIiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiI0OTI0NDAyMDA3NjYtMGZxc2toYjZlYnRhZzFobHFwbzdmbzkzY3VhYXJzbDYuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJhdWQiOiI0OTI0NDAyMDA3NjYtZjE0Yjl0OXRtcmF1bGg2N2dxb2JhYTlpc3EzN2cwbmMuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJzdWIiOiIxMDUzNzAxODc3MDQyMDc4MjU2MjUiLCJlbWFpbCI6ImNhaXlhbnBlbmcwNjE5QGdtYWlsLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJuYW1lIjoi6JSh5Lil6bmPIiwicGljdHVyZSI6Imh0dHBzOi8vbGgzLmdvb2dsZXVzZXJjb250ZW50LmNvbS9hL0FBVFhBSnhjeWVkS05iZkcwZ3lIbkRhMXpWemVZRGVpdXI3OHUtNWZfbnVWPXM5Ni1jIiwiZ2l2ZW5fbmFtZSI6IuS4pem5jyIsImZhbWlseV9uYW1lIjoi6JShIiwibG9jYWxlIjoiemgtQ04iLCJpYXQiOjE2NDI0ODUxNzEsImV4cCI6MTY0MjQ4ODc3MX0.ZX-9jmB9GaWQEgcv8jbd4Ojy33DiVvl7m_PQZudJEQaLC1S5C6QJOaZRJEHNQ44mWmfSPlHPEhgsEoP-Qn7lKx7r609OuzMYGUE266bdbYer2KzztMtZIUKrI3i0UGLlybQm8YVGJh4vTvtaLZ3Fi2h2aKlDjx4MvFDaQKIwTDsOXzkCmhidYJ4KOhCToZsGIWmR8OhtwhL531p1oV3kOW28nXSbPhl0GalEbu-n970TtpxxQRvJeK61V8R3F29U71pn9PI863xQQ4itWsvQaFNz03pC8RRBGEKN8dvrmTqbKMuoo44fV4pLiY66EqUUoKYST7dOl15zUGfC-ckq5g");
+#elif UNITY_IOS
+ App.weChatController.SignWithGoogle();
#else
Utils.CallAndroidMethod("signInWithGoogle");
#endif
@@ -208,7 +210,6 @@ public class LoginControllerMobile : MonoBehaviour, INativeOnMobileWxLoginResp
public void OnMobileGoogleLoginResp(string res)
{
Debug.Log(res);
-#if UNITY_ANDROID
var sp = res.Replace("true;", "").Split('|');
if (sp.Length == 2)
{
@@ -218,7 +219,6 @@ public class LoginControllerMobile : MonoBehaviour, INativeOnMobileWxLoginResp
{
Utils.showToast(null, res.Replace("false;",""));
}
-#endif
}
public void OnAppleResp(string res)
diff --git a/Assets/Scripts/Mobile/WeChatController.cs b/Assets/Scripts/Mobile/WeChatController.cs
index c76a3eb6..40b01a1f 100644
--- a/Assets/Scripts/Mobile/WeChatController.cs
+++ b/Assets/Scripts/Mobile/WeChatController.cs
@@ -36,6 +36,8 @@ public class WeChatController
[DllImport("__Internal")]
private static extern void authorizationAppleID();
+ [DllImport("__Internal")]
+ private static extern void authorizationGoogleID();
#endif
#endregion
///
@@ -83,6 +85,13 @@ public class WeChatController
#endif
}
+ public void SignWithGoogle()
+ {
+#if UNITY_IOS
+ authorizationGoogleID();
+#endif
+ }
+
///
/// 判断是否是否安装了微信
///
diff --git a/Assets/Scripts/Utils/Utils.cs b/Assets/Scripts/Utils/Utils.cs
index 91a2af76..7917d36c 100644
--- a/Assets/Scripts/Utils/Utils.cs
+++ b/Assets/Scripts/Utils/Utils.cs
@@ -280,7 +280,7 @@ namespace Assets.Scripts
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
var activity = jc.GetStatic("currentActivity");
return activity.Call("CheckGooglePlayServices");
-#elif UNITY_EDITOR
+#elif UNITY_EDITOR || UNITY_IOS
return true;
#else
return false;