Skip to content

Commit 05149d7

Browse files
committed
2 parents 4076119 + 6b90f62 commit 05149d7

File tree

10 files changed

+28
-145
lines changed

10 files changed

+28
-145
lines changed

Assets/Plugins/Web3AuthSDK/Editor/BuildPostProcess.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class BuildPostProcess
1313
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
1414
{
1515
#if UNITY_IOS
16-
/*
16+
1717
Uri uri = null;
1818

1919
try
@@ -39,7 +39,7 @@ public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProj
3939
urlSchemes.AddString(uri.Scheme);
4040

4141
infoPlist.WriteToFile(infoPlistPath);
42-
*/
42+
4343

4444
#endif
4545
}

Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.unity

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,8 +886,8 @@ MonoBehaviour:
886886
m_Script: {fileID: 11500000, guid: 3eab2a0bf902d6e4b9c2e968ad89f528, type: 3}
887887
m_Name:
888888
m_EditorClassIdentifier:
889-
clientId: BJYIrHuzluClBK0vvTBUJ7kQylV_Dj3NA-X1q4Qvxs2Ay3DySkacOpoOb83lDTHJRVY83bFlYtt4p8pQR-oCYtw
890-
redirectUri: com.web3auth.sdkapp://auth
889+
clientId: BAwFgL-r7wzQKmtcdiz2uHJKNZdK7gzEf2q-m55xfzSZOw8jLOyIi4AVvvzaEQO5nv2dFLEmf9LBkF8kaq3aErg
890+
redirectUri: torusapp://com.torus.Web3AuthUnity/auth
891891
network: 1
892892
--- !u!1 &529774071
893893
GameObject:

Assets/Plugins/Web3AuthSDK/Utils.cs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,13 @@
88

99
public static class Utils
1010
{
11-
//https://qiita.com/lucifuges/items/b17d602417a9a249689f
1211
#if UNITY_IOS
1312
[DllImport("__Internal")]
14-
extern static void launchUrl(string url);
15-
[DllImport("__Internal")]
16-
extern static void dismiss();
17-
[DllImport("__Internal")]
18-
extern static void _web3auth_launch(string url, string redirectUri);
13+
extern static void web3auth_launch(string url, string redirectUri, string objectName);
1914
#endif
2015

2116

22-
public static void LaunchUrl(string url, string redirectUri = null)
17+
public static void LaunchUrl(string url, string redirectUri = null, string objectName = null)
2318
{
2419
Debug.Log((new Uri(redirectUri)).Scheme);
2520
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
@@ -34,15 +29,7 @@ public static void LaunchUrl(string url, string redirectUri = null)
3429

3530
#elif UNITY_IOS
3631
var uri = new Uri(redirectUri);
37-
_web3auth_launch(url, uri.Scheme);
38-
//launchUrl(url);
39-
#endif
40-
}
41-
42-
public static void Dismiss()
43-
{
44-
#if UNITY_IOS && !UNITY_EDITOR
45-
dismiss();
32+
web3auth_launch(url, uri.Scheme, objectName);
4633
#endif
4734
}
4835

Assets/Plugins/Web3AuthSDK/Web3Auth.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ private void request(string path, LoginParams loginParams = null, Dictionary<st
214214
uriBuilder.Path = path;
215215
uriBuilder.Fragment = hash;
216216

217-
Utils.LaunchUrl(uriBuilder.ToString(), this.initParams["redirectUrl"].ToString());
217+
Utils.LaunchUrl(uriBuilder.ToString(), this.initParams["redirectUrl"].ToString(), gameObject.name);
218218
}
219219

220220
public void setResultUrl(Uri uri)
@@ -239,9 +239,6 @@ public void setResultUrl(Uri uri)
239239
else
240240
this.Enqueue(() => this.onLogin?.Invoke(this.web3AuthResponse));
241241

242-
#if UNITY_IOS
243-
Utils.Dismiss();
244-
#endif
245242
}
246243

247244
public void login(LoginParams loginParams)

Assets/Plugins/Web3AuthSDK/iOS/SafariView.mm

Lines changed: 0 additions & 24 deletions
This file was deleted.

Assets/Plugins/Web3AuthSDK/iOS/SafariView.mm.meta

Lines changed: 0 additions & 80 deletions
This file was deleted.

Assets/Plugins/Web3AuthSDK/iOS/WebAuthenticate.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#import <UnityFramework/UnityFramework-Swift.h>
1111

1212
extern "C" {
13-
void _web3auth_launch(const char *url, const char *redirectUri) {
14-
[WebAuthenticate launch:[NSString stringWithUTF8String:url] :[NSString stringWithUTF8String:redirectUri]];
13+
void web3auth_launch(const char *url, const char *redirectUri, const char *objectName) {
14+
[WebAuthenticate launch:[NSString stringWithUTF8String:url] :[NSString stringWithUTF8String:redirectUri] :[NSString stringWithUTF8String:objectName]];
1515
}
1616
}

Assets/Plugins/Web3AuthSDK/iOS/WebAuthenticate.swift

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,39 @@ import AuthenticationServices
22
import SafariServices
33
import UIKit
44

5+
56
@objc public class WebAuthenticate: NSObject {
67
public static let instance = WebAuthenticate();
8+
public static var authSession: ASWebAuthenticationSession? = nil;
79

8-
@objc public func call(_ url: String,_ redirectUri: String) {
9-
let authSession = ASWebAuthenticationSession(
10+
@objc public func call(_ url: String,_ redirectUri: String,_ objectName: String) {
11+
WebAuthenticate.authSession = ASWebAuthenticationSession(
1012
url: URL(string: url)!, callbackURLScheme: redirectUri) { callbackURL, authError in
11-
12-
print("hello world");
13+
guard authError == nil, let callbackURL = callbackURL else {
14+
return
15+
}
16+
1317
let unity = UnityFramework.getInstance();
14-
unity?.sendMessageToGO(withName: "Web3Auth", functionName: "onDeepLinkActivated", message: callbackURL?.absoluteString);
18+
unity?.sendMessageToGO(withName: objectName, functionName: "onDeepLinkActivated", message: callbackURL.absoluteString);
1519
}
1620

1721
if #available(iOS 13.0, *) {
18-
authSession.presentationContextProvider = self
19-
authSession.prefersEphemeralWebBrowserSession = true
22+
WebAuthenticate.authSession?.presentationContextProvider = self
23+
WebAuthenticate.authSession?.prefersEphemeralWebBrowserSession = true
2024
}
2125

22-
authSession.start();
26+
WebAuthenticate.authSession?.start();
2327
}
2428

25-
@objc public static func launch(_ url: String,_ redirectUri: String) {
26-
instance.call(url, redirectUri);
29+
@objc public static func launch(_ url: String,_ redirectUri: String,_ objectName: String) {
30+
instance.call(url, redirectUri, objectName);
2731
}
2832
}
2933

3034

3135
@available(iOS 12.0, *)
3236
extension WebAuthenticate: ASWebAuthenticationPresentationContextProviding {
3337
public func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
34-
let window = UIApplication.shared.windows.first { $0.isKeyWindow }
35-
return window ?? ASPresentationAnchor()
38+
return UnityFramework.getInstance().appController().window;
3639
}
3740
}

Assets/Resources/webauth

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
torusapp://org.torusresearch.web3authunity/auth
1+
torusapp://com.torus.Web3AuthUnity/auth

ProjectSettings/ProjectSettings.asset

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,12 @@ PlayerSettings:
157157
applicationIdentifier:
158158
Android: org.torusresearch.web3authunitysdk
159159
Standalone: org.torusresearch.web3authunitysdk
160-
iPhone: com.web3auth.sdkapp
160+
iPhone: com.torusresearch.web3auth-unity-sdk
161161
buildNumber:
162162
Standalone: 0
163163
iPhone: 0
164164
tvOS: 0
165-
overrideDefaultApplicationIdentifier: 1
165+
overrideDefaultApplicationIdentifier: 0
166166
AndroidBundleVersionCode: 1
167167
AndroidMinSdkVersion: 24
168168
AndroidTargetSdkVersion: 0

0 commit comments

Comments
 (0)