ios端google;修改ios打包时pod数据源为清华
This commit is contained in:
parent
58a8233697
commit
7bb5bafbd2
@ -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");
|
||||
|
||||
@ -14,5 +14,7 @@
|
||||
<iosPod name="FBSDKLoginKit" version="~> 11.0" />
|
||||
<iosPod name="FBSDKShareKit" version="~> 11.0" />
|
||||
<iosPod name="FBSDKGamingServicesKit" version="~> 11.0" />
|
||||
<iosPod name="Firebase/Auth" />
|
||||
<iosPod name="GoogleSignIn" />
|
||||
</iosPods>
|
||||
</dependencies>
|
||||
|
||||
Binary file not shown.
36
Assets/Plugins/iOS/GoogleService-Info.plist
Normal file
36
Assets/Plugins/iOS/GoogleService-Info.plist
Normal file
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CLIENT_ID</key>
|
||||
<string>492440200766-spo9287smn7epmlarib2pek9kficsq86.apps.googleusercontent.com</string>
|
||||
<key>REVERSED_CLIENT_ID</key>
|
||||
<string>com.googleusercontent.apps.492440200766-spo9287smn7epmlarib2pek9kficsq86</string>
|
||||
<key>ANDROID_CLIENT_ID</key>
|
||||
<string>492440200766-0fqskhb6ebtag1hlqpo7fo93cuaarsl6.apps.googleusercontent.com</string>
|
||||
<key>API_KEY</key>
|
||||
<string>AIzaSyCapHL0ck1BuzfS2Drbup4VRO0jf_9fp_U</string>
|
||||
<key>GCM_SENDER_ID</key>
|
||||
<string>492440200766</string>
|
||||
<key>PLIST_VERSION</key>
|
||||
<string>1</string>
|
||||
<key>BUNDLE_ID</key>
|
||||
<string>com.ZhiXingPai.PowerFun</string>
|
||||
<key>PROJECT_ID</key>
|
||||
<string>powerfun-c1019</string>
|
||||
<key>STORAGE_BUCKET</key>
|
||||
<string>powerfun-c1019.appspot.com</string>
|
||||
<key>IS_ADS_ENABLED</key>
|
||||
<false></false>
|
||||
<key>IS_ANALYTICS_ENABLED</key>
|
||||
<false></false>
|
||||
<key>IS_APPINVITE_ENABLED</key>
|
||||
<true></true>
|
||||
<key>IS_GCM_ENABLED</key>
|
||||
<true></true>
|
||||
<key>IS_SIGNIN_ENABLED</key>
|
||||
<true></true>
|
||||
<key>GOOGLE_APP_ID</key>
|
||||
<string>1:492440200766:ios:87037cb11ad738c0e4d36f</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@ -1,6 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ccd268c2c2c420741bbf29cb19e4aada
|
||||
folderAsset: yes
|
||||
guid: 8f722ab35ffa939418fdbda7f0793bc7
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
@ -14,6 +14,8 @@
|
||||
#import <FBSDKShareKit/FBSDKShareKit.h>
|
||||
#import <FBSDKGamingServicesKit/FBSDKGamingServicesKit.h>
|
||||
#import <Foundation/NSJSONSerialization.h>
|
||||
@import Firebase;
|
||||
@import GoogleSignIn;
|
||||
|
||||
extern void UnitySendMessage(const char *,const char *,const char *);
|
||||
@interface IOSWechatController : UnityAppController<WXApiDelegate>
|
||||
@ -49,6 +51,12 @@ options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
|
||||
return [WXApi handleOpenURL:url delegate:self];
|
||||
}
|
||||
|
||||
- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
//google登录
|
||||
[FIRApp configure];
|
||||
}
|
||||
|
||||
- (void)onResp:(BaseResp *)resp
|
||||
{
|
||||
NSLog(@"47");
|
||||
|
||||
15
Assets/Plugins/iOS/Podfile
Normal file
15
Assets/Plugins/iOS/Podfile
Normal file
@ -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!
|
||||
7
Assets/Plugins/iOS/Podfile.meta
Normal file
7
Assets/Plugins/iOS/Podfile.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f168de8faf0b96c4f8bf9708edb05015
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,4 +1,7 @@
|
||||
# import <AuthenticationServices/AuthenticationServices.h>
|
||||
#import <AuthenticationServices/AuthenticationServices.h>
|
||||
@import Firebase;
|
||||
@import GoogleSignIn;
|
||||
#import "UnityAppController.h"
|
||||
|
||||
@interface AppleAuth: NSObject<ASAuthorizationControllerDelegate,ASAuthorizationProvider>
|
||||
- (void)authorizationAppleID;
|
||||
|
||||
@ -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];
|
||||
}
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -36,6 +36,8 @@ public class WeChatController
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void authorizationAppleID();
|
||||
[DllImport("__Internal")]
|
||||
private static extern void authorizationGoogleID();
|
||||
#endif
|
||||
#endregion
|
||||
/// <summary>
|
||||
@ -83,6 +85,13 @@ public class WeChatController
|
||||
#endif
|
||||
}
|
||||
|
||||
public void SignWithGoogle()
|
||||
{
|
||||
#if UNITY_IOS
|
||||
authorizationGoogleID();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断是否是否安装了微信
|
||||
/// </summary>
|
||||
|
||||
@ -280,7 +280,7 @@ namespace Assets.Scripts
|
||||
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
|
||||
var activity = jc.GetStatic<AndroidJavaObject>("currentActivity");
|
||||
return activity.Call<bool>("CheckGooglePlayServices");
|
||||
#elif UNITY_EDITOR
|
||||
#elif UNITY_EDITOR || UNITY_IOS
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user