Skip to content

Commit 5e5f934

Browse files
authored
Merge pull request #839 from Web3Auth/fix/ios-samples
Update iOS Examples
2 parents 9d6305b + 25aba34 commit 5e5f934

File tree

24 files changed

+238
-241
lines changed

24 files changed

+238
-241
lines changed

ios/ios-aggregate-verifier-example/ios-aggregate-example.xcodeproj/project.pbxproj

+7-7
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@
457457
"@executable_path/Frameworks",
458458
);
459459
MARKETING_VERSION = 1.0;
460-
PRODUCT_BUNDLE_IDENTIFIER = "Web3Auth.ios-aggregate-example";
460+
PRODUCT_BUNDLE_IDENTIFIER = "web3auth.ios-aggregate-example";
461461
PRODUCT_NAME = "$(TARGET_NAME)";
462462
SWIFT_EMIT_LOC_STRINGS = YES;
463463
SWIFT_VERSION = 5.0;
@@ -485,7 +485,7 @@
485485
"@executable_path/Frameworks",
486486
);
487487
MARKETING_VERSION = 1.0;
488-
PRODUCT_BUNDLE_IDENTIFIER = "Web3Auth.ios-aggregate-example";
488+
PRODUCT_BUNDLE_IDENTIFIER = "web3auth.ios-aggregate-example";
489489
PRODUCT_NAME = "$(TARGET_NAME)";
490490
SWIFT_EMIT_LOC_STRINGS = YES;
491491
SWIFT_VERSION = 5.0;
@@ -503,7 +503,7 @@
503503
GENERATE_INFOPLIST_FILE = YES;
504504
IPHONEOS_DEPLOYMENT_TARGET = 15.5;
505505
MARKETING_VERSION = 1.0;
506-
PRODUCT_BUNDLE_IDENTIFIER = "Web3Auth.ios-aggregate-exampleTests";
506+
PRODUCT_BUNDLE_IDENTIFIER = "web3auth.ios-aggregate-exampletests";
507507
PRODUCT_NAME = "$(TARGET_NAME)";
508508
SWIFT_EMIT_LOC_STRINGS = NO;
509509
SWIFT_VERSION = 5.0;
@@ -522,7 +522,7 @@
522522
GENERATE_INFOPLIST_FILE = YES;
523523
IPHONEOS_DEPLOYMENT_TARGET = 15.5;
524524
MARKETING_VERSION = 1.0;
525-
PRODUCT_BUNDLE_IDENTIFIER = "Web3Auth.ios-aggregate-exampleTests";
525+
PRODUCT_BUNDLE_IDENTIFIER = "web3auth.ios-aggregate-exampletests";
526526
PRODUCT_NAME = "$(TARGET_NAME)";
527527
SWIFT_EMIT_LOC_STRINGS = NO;
528528
SWIFT_VERSION = 5.0;
@@ -539,7 +539,7 @@
539539
CURRENT_PROJECT_VERSION = 1;
540540
GENERATE_INFOPLIST_FILE = YES;
541541
MARKETING_VERSION = 1.0;
542-
PRODUCT_BUNDLE_IDENTIFIER = "Web3Auth.ios-aggregate-exampleUITests";
542+
PRODUCT_BUNDLE_IDENTIFIER = "web3auth.ios-aggregate-exampleuitests";
543543
PRODUCT_NAME = "$(TARGET_NAME)";
544544
SWIFT_EMIT_LOC_STRINGS = NO;
545545
SWIFT_VERSION = 5.0;
@@ -556,7 +556,7 @@
556556
CURRENT_PROJECT_VERSION = 1;
557557
GENERATE_INFOPLIST_FILE = YES;
558558
MARKETING_VERSION = 1.0;
559-
PRODUCT_BUNDLE_IDENTIFIER = "Web3Auth.ios-aggregate-exampleUITests";
559+
PRODUCT_BUNDLE_IDENTIFIER = "web3auth.ios-aggregate-exampleuitests";
560560
PRODUCT_NAME = "$(TARGET_NAME)";
561561
SWIFT_EMIT_LOC_STRINGS = NO;
562562
SWIFT_VERSION = 5.0;
@@ -612,7 +612,7 @@
612612
repositoryURL = "https://github.com/web3auth/web3auth-swift-sdk";
613613
requirement = {
614614
kind = upToNextMajorVersion;
615-
minimumVersion = 7.4.1;
615+
minimumVersion = 7.5.0;
616616
};
617617
};
618618
/* End XCRemoteSwiftPackageReference section */

ios/ios-aggregate-verifier-example/ios-aggregate-example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@
149149
"kind" : "remoteSourceControl",
150150
"location" : "https://github.com/web3auth/web3auth-swift-sdk",
151151
"state" : {
152-
"revision" : "4c00016bed255f91808547eb43241519440686ed",
153-
"version" : "7.4.1"
152+
"revision" : "5de95f8eaa5ca7847c6d93daddc13ce51eb2b1f0",
153+
"version" : "7.5.0"
154154
}
155155
},
156156
{

ios/ios-aggregate-verifier-example/ios-aggregate-example/ContentView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct ContentView: View {
1111
ProgressView()
1212
} else {
1313
if vm.loggedIn,let user = vm.user, let web3rpc = Web3RPC(user: user) {
14-
UserDetailView(user: vm.user, loggedIn: $vm.loggedIn, web3RPC: web3rpc)
14+
UserDetailView(web3RPC: web3rpc, viewModel: vm)
1515
} else {
1616
LoginView(vm: vm)
1717
}

ios/ios-aggregate-verifier-example/ios-aggregate-example/UserDetailView.swift

+5-15
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import Web3Auth
33
import web3
44

55
struct UserDetailView: View {
6-
@State var user: Web3AuthState?
7-
@Binding var loggedIn: Bool
86
@State private var showingAlert = false
97
@StateObject var web3RPC: Web3RPC
8+
@StateObject var viewModel: ViewModel
9+
1010
var body: some View {
11-
if let user = user {
11+
if let user = viewModel.user {
1212
List {
1313
Section {
1414
Text("\(user.privKey ?? "")")
@@ -86,11 +86,8 @@ struct UserDetailView: View {
8686
Button {
8787
Task.detached {
8888
do {
89-
try await Web3Auth(.init(clientId: "BHr_dKcxC0ecKn_2dZQmQeNdjPgWykMkcodEHkVvPMo71qzOV6SgtoN8KCvFdLN7bf34JOm89vWQMLFmSfIo84A",
90-
network: .mainnet)).logout()
91-
await MainActor.run(body: {
92-
loggedIn.toggle()
93-
}) } catch {
89+
try await viewModel.logout()
90+
} catch {
9491
DispatchQueue.main.async {
9592
showingAlert = true
9693
}
@@ -109,10 +106,3 @@ struct UserDetailView: View {
109106
}
110107
}
111108
}
112-
113-
struct UserDetailView_Previews: PreviewProvider {
114-
static var previews: some View {
115-
let user: Web3AuthState = .init(privKey: "12345", ed25519PrivKey: "32334", sessionId: "23234384y7735y47shdj", userInfo: nil, error: nil, coreKitKey: "45676", coreKitEd25519PrivKey: "84567")
116-
UserDetailView(user: user , loggedIn: .constant(true), web3RPC: .init(user: user)!)
117-
}
118-
}

ios/ios-aggregate-verifier-example/ios-aggregate-example/ViewModel.swift

+43-45
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,50 @@ import Foundation
22
import Web3Auth
33

44
class ViewModel: ObservableObject {
5-
var web3Auth: Web3Auth?
5+
lazy var web3Auth: Web3Auth? = nil
66
@Published var loggedIn: Bool = false
77
@Published var user: Web3AuthState?
88
@Published var isLoading = false
99
@Published var navigationTitle: String = ""
10-
private var clientId = "BHr_dKcxC0ecKn_2dZQmQeNdjPgWykMkcodEHkVvPMo71qzOV6SgtoN8KCvFdLN7bf34JOm89vWQMLFmSfIo84A"
11-
private var network: Network = .testnet
10+
private var clientId = "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ"
11+
private var network: Network = .sapphire_mainnet
12+
1213
func setup() async {
1314
guard web3Auth == nil else { return }
1415
await MainActor.run(body: {
1516
isLoading = true
1617
navigationTitle = "Loading"
1718
})
18-
web3Auth = await Web3Auth(.init(clientId: clientId, network: network))
19+
web3Auth = await Web3Auth(W3AInitParams(
20+
clientId: clientId, network: network,
21+
loginConfig: [
22+
TypeOfLogin.google.rawValue:
23+
.init(
24+
verifier: "aggregate-sapphire",
25+
typeOfLogin: .google,
26+
name: "Web3Auth-Aggregate-Verifier-Google-Example",
27+
clientId: "519228911939-cri01h55lsjbsia1k7ll6qpalrus75ps.apps.googleusercontent.com",
28+
verifierSubIdentifier: "w3a-google"
29+
)
30+
],
31+
whiteLabel: W3AWhiteLabelData(
32+
appName: "Web3Auth Stub",
33+
logoLight: "https://images.web3auth.io/web3auth-logo-w.svg",
34+
logoDark: "https://images.web3auth.io/web3auth-logo-w.svg",
35+
defaultLanguage: .en, // en, de, ja, ko, zh, es, fr, pt, nl
36+
mode: .dark,
37+
theme: ["primary": "#d53f8c"]
38+
),
39+
mfaSettings: MfaSettings(
40+
deviceShareFactor: MfaSetting(enable: true, priority: 1),
41+
backUpShareFactor: MfaSetting(enable: true, priority: 2),
42+
socialBackupFactor: MfaSetting(enable: true, priority: 3),
43+
passwordFactor: MfaSetting(enable: true, priority: 4)
44+
),
45+
// 259200 allows user to stay authenticated for 3 days with Web3Auth.
46+
// Default is 86400, which is 1 day.
47+
sessionTime: 259200
48+
))
1949
await MainActor.run(body: {
2050
if self.web3Auth?.state != nil {
2151
user = web3Auth?.state
@@ -29,33 +59,7 @@ class ViewModel: ObservableObject {
2959
func loginWithGoogle() {
3060
Task{
3161
do {
32-
let result = try await Web3Auth(.init(
33-
clientId: clientId,
34-
network: network,
35-
loginConfig: [
36-
TypeOfLogin.google.rawValue:
37-
.init(
38-
verifier: "w3a-agg-example",
39-
typeOfLogin: .google,
40-
name: "Web3Auth-Aggregate-Verifier-Google-Example",
41-
clientId: "774338308167-q463s7kpvja16l4l0kko3nb925ikds2p.apps.googleusercontent.com",
42-
verifierSubIdentifier: "w3a-google"
43-
)
44-
],
45-
whiteLabel: W3AWhiteLabelData(
46-
appName: "Web3Auth Stub",
47-
logoLight: "https://images.web3auth.io/web3auth-logo-w.svg",
48-
logoDark: "https://images.web3auth.io/web3auth-logo-w.svg",
49-
defaultLanguage: .en, // en, de, ja, ko, zh, es, fr, pt, nl
50-
mode: .dark,
51-
theme: ["primary": "#d53f8c"]),
52-
mfaSettings: MfaSettings(
53-
deviceShareFactor: MfaSetting(enable: true, priority: 1),
54-
backUpShareFactor: MfaSetting(enable: true, priority: 2),
55-
socialBackupFactor: MfaSetting(enable: true, priority: 3),
56-
passwordFactor: MfaSetting(enable: true, priority: 4)
57-
)
58-
)).login(
62+
let result = try await web3Auth?.login(
5963
W3ALoginParams(
6064
loginProvider: .GOOGLE,
6165
dappShare: nil,
@@ -76,20 +80,7 @@ class ViewModel: ObservableObject {
7680
func loginWithGitHub() {
7781
Task{
7882
do {
79-
let result = try await Web3Auth(.init(
80-
clientId: clientId,
81-
network: network,
82-
loginConfig: [
83-
TypeOfLogin.jwt.rawValue:
84-
.init(
85-
verifier: "w3a-agg-example",
86-
typeOfLogin: .jwt,
87-
name: "Web3Auth-Aggregate-Verifier-GitHub-Example",
88-
clientId: "hiLqaop0amgzCC0AXo4w0rrG9abuJTdu",
89-
verifierSubIdentifier: "w3a-a0-github"
90-
)
91-
]
92-
)).login(
83+
let result = try await web3Auth?.login(
9384
W3ALoginParams(
9485
loginProvider: .JWT,
9586
dappShare: nil,
@@ -106,6 +97,13 @@ class ViewModel: ObservableObject {
10697
}
10798
}
10899
}
100+
101+
func logout() async throws {
102+
try await web3Auth?.logout()
103+
await MainActor.run(body: {
104+
loggedIn = false
105+
})
106+
}
109107
}
110108

111109
extension ViewModel {

ios/ios-aggregate-verifier-example/ios-aggregate-example/web3RPC.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ class Web3RPC : ObservableObject {
2424
self.user = user
2525
do{
2626
client = EthereumHttpClient(url: URL(string: RPC_URL)!)
27-
account = try EthereumAccount(keyStorage: user as! EthereumSingleKeyStorageProtocol )
27+
account = try EthereumAccount(keyStorage: user as EthereumSingleKeyStorageProtocol )
2828
address = account.address
2929
} catch {
3030
return nil
3131
}
3232
}
3333

3434
func getAccounts() {
35-
self.publicAddress = address.value
36-
print(address.value)
35+
self.publicAddress = address.asString()
36+
print(address.asString())
3737
}
3838

3939

ios/ios-auth0-example/ios-auth0-example.xcodeproj/project.pbxproj

+15-15
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
2810C9532B63652A00BCE94C /* Web3Auth in Frameworks */ = {isa = PBXBuildFile; productRef = 2810C9522B63652A00BCE94C /* Web3Auth */; };
1011
4D9FEEE5294BAC380035414D /* ios_auth0_exampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9FEEE4294BAC380035414D /* ios_auth0_exampleApp.swift */; };
1112
4D9FEEE7294BAC380035414D /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9FEEE6294BAC380035414D /* ContentView.swift */; };
1213
4D9FEEE9294BAC3A0035414D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4D9FEEE8294BAC3A0035414D /* Assets.xcassets */; };
1314
4D9FEEEC294BAC3A0035414D /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4D9FEEEB294BAC3A0035414D /* Preview Assets.xcassets */; };
1415
4D9FEEF6294BAC3A0035414D /* ios_auth0_exampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9FEEF5294BAC3A0035414D /* ios_auth0_exampleTests.swift */; };
1516
4D9FEF00294BAC3A0035414D /* ios_auth0_exampleUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9FEEFF294BAC3A0035414D /* ios_auth0_exampleUITests.swift */; };
1617
4D9FEF02294BAC3A0035414D /* ios_auth0_exampleUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9FEF01294BAC3A0035414D /* ios_auth0_exampleUITestsLaunchTests.swift */; };
17-
4D9FEF10294BAC850035414D /* Web3Auth in Frameworks */ = {isa = PBXBuildFile; productRef = 4D9FEF0F294BAC850035414D /* Web3Auth */; };
1818
4D9FEF12294BACB10035414D /* ViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9FEF11294BACB10035414D /* ViewModel.swift */; };
1919
4D9FEF14294BACC90035414D /* UserDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9FEF13294BACC90035414D /* UserDetailView.swift */; };
2020
4D9FEF16294BACD80035414D /* LoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9FEF15294BACD80035414D /* LoginView.swift */; };
@@ -62,7 +62,7 @@
6262
isa = PBXFrameworksBuildPhase;
6363
buildActionMask = 2147483647;
6464
files = (
65-
4D9FEF10294BAC850035414D /* Web3Auth in Frameworks */,
65+
2810C9532B63652A00BCE94C /* Web3Auth in Frameworks */,
6666
);
6767
runOnlyForDeploymentPostprocessing = 0;
6868
};
@@ -161,7 +161,7 @@
161161
);
162162
name = "ios-auth0-example";
163163
packageProductDependencies = (
164-
4D9FEF0F294BAC850035414D /* Web3Auth */,
164+
2810C9522B63652A00BCE94C /* Web3Auth */,
165165
);
166166
productName = "ios-auth0-example";
167167
productReference = 4D9FEEE1294BAC380035414D /* ios-auth0-example.app */;
@@ -236,7 +236,7 @@
236236
);
237237
mainGroup = 4D9FEED8294BAC380035414D;
238238
packageReferences = (
239-
4D9FEF0E294BAC850035414D /* XCRemoteSwiftPackageReference "web3auth-swift-sdk" */,
239+
2810C9512B63652A00BCE94C /* XCRemoteSwiftPackageReference "web3auth-swift-sdk" */,
240240
);
241241
productRefGroup = 4D9FEEE2294BAC380035414D /* Products */;
242242
projectDirPath = "";
@@ -457,7 +457,7 @@
457457
"@executable_path/Frameworks",
458458
);
459459
MARKETING_VERSION = 1.0;
460-
PRODUCT_BUNDLE_IDENTIFIER = "Web3Auth.ios-auth0-example";
460+
PRODUCT_BUNDLE_IDENTIFIER = "web3auth.ios-auth0-example";
461461
PRODUCT_NAME = "$(TARGET_NAME)";
462462
SWIFT_EMIT_LOC_STRINGS = YES;
463463
SWIFT_VERSION = 5.0;
@@ -485,7 +485,7 @@
485485
"@executable_path/Frameworks",
486486
);
487487
MARKETING_VERSION = 1.0;
488-
PRODUCT_BUNDLE_IDENTIFIER = "Web3Auth.ios-auth0-example";
488+
PRODUCT_BUNDLE_IDENTIFIER = "web3auth.ios-auth0-example";
489489
PRODUCT_NAME = "$(TARGET_NAME)";
490490
SWIFT_EMIT_LOC_STRINGS = YES;
491491
SWIFT_VERSION = 5.0;
@@ -503,7 +503,7 @@
503503
GENERATE_INFOPLIST_FILE = YES;
504504
IPHONEOS_DEPLOYMENT_TARGET = 15.5;
505505
MARKETING_VERSION = 1.0;
506-
PRODUCT_BUNDLE_IDENTIFIER = "Web3Auth.ios-auth0-exampleTests";
506+
PRODUCT_BUNDLE_IDENTIFIER = "web3auth.ios-auth0-exampletests";
507507
PRODUCT_NAME = "$(TARGET_NAME)";
508508
SWIFT_EMIT_LOC_STRINGS = NO;
509509
SWIFT_VERSION = 5.0;
@@ -522,7 +522,7 @@
522522
GENERATE_INFOPLIST_FILE = YES;
523523
IPHONEOS_DEPLOYMENT_TARGET = 15.5;
524524
MARKETING_VERSION = 1.0;
525-
PRODUCT_BUNDLE_IDENTIFIER = "Web3Auth.ios-auth0-exampleTests";
525+
PRODUCT_BUNDLE_IDENTIFIER = "web3auth.ios-auth0-exampletests";
526526
PRODUCT_NAME = "$(TARGET_NAME)";
527527
SWIFT_EMIT_LOC_STRINGS = NO;
528528
SWIFT_VERSION = 5.0;
@@ -539,7 +539,7 @@
539539
CURRENT_PROJECT_VERSION = 1;
540540
GENERATE_INFOPLIST_FILE = YES;
541541
MARKETING_VERSION = 1.0;
542-
PRODUCT_BUNDLE_IDENTIFIER = "Web3Auth.ios-auth0-exampleUITests";
542+
PRODUCT_BUNDLE_IDENTIFIER = "web3auth.ios-auth0-exampleuiItests";
543543
PRODUCT_NAME = "$(TARGET_NAME)";
544544
SWIFT_EMIT_LOC_STRINGS = NO;
545545
SWIFT_VERSION = 5.0;
@@ -556,7 +556,7 @@
556556
CURRENT_PROJECT_VERSION = 1;
557557
GENERATE_INFOPLIST_FILE = YES;
558558
MARKETING_VERSION = 1.0;
559-
PRODUCT_BUNDLE_IDENTIFIER = "Web3Auth.ios-auth0-exampleUITests";
559+
PRODUCT_BUNDLE_IDENTIFIER = "web3auth.ios-auth0-exampleuiItests";
560560
PRODUCT_NAME = "$(TARGET_NAME)";
561561
SWIFT_EMIT_LOC_STRINGS = NO;
562562
SWIFT_VERSION = 5.0;
@@ -607,20 +607,20 @@
607607
/* End XCConfigurationList section */
608608

609609
/* Begin XCRemoteSwiftPackageReference section */
610-
4D9FEF0E294BAC850035414D /* XCRemoteSwiftPackageReference "web3auth-swift-sdk" */ = {
610+
2810C9512B63652A00BCE94C /* XCRemoteSwiftPackageReference "web3auth-swift-sdk" */ = {
611611
isa = XCRemoteSwiftPackageReference;
612-
repositoryURL = "https://github.com/web3auth/web3auth-swift-sdk";
612+
repositoryURL = "https://github.com/Web3Auth/web3auth-swift-sdk/";
613613
requirement = {
614614
kind = upToNextMajorVersion;
615-
minimumVersion = 7.4.1;
615+
minimumVersion = 7.5.0;
616616
};
617617
};
618618
/* End XCRemoteSwiftPackageReference section */
619619

620620
/* Begin XCSwiftPackageProductDependency section */
621-
4D9FEF0F294BAC850035414D /* Web3Auth */ = {
621+
2810C9522B63652A00BCE94C /* Web3Auth */ = {
622622
isa = XCSwiftPackageProductDependency;
623-
package = 4D9FEF0E294BAC850035414D /* XCRemoteSwiftPackageReference "web3auth-swift-sdk" */;
623+
package = 2810C9512B63652A00BCE94C /* XCRemoteSwiftPackageReference "web3auth-swift-sdk" */;
624624
productName = Web3Auth;
625625
};
626626
/* End XCSwiftPackageProductDependency section */

0 commit comments

Comments
 (0)