Skip to content

Commit d13d894

Browse files
authored
Update GoogleSignin to version 5, primarily to fix the dependency on the deprecated UIWebView API. Bump the plug-in version to 1.5.1. (#38)
1 parent 80cb0bb commit d13d894

File tree

7 files changed

+112
-124
lines changed

7 files changed

+112
-124
lines changed

CodetrixStudioCapacitorGoogleAuth.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
1111
s.ios.deployment_target = '11.0'
1212
s.dependency 'Capacitor'
13-
s.dependency 'GoogleSignIn', '< 5'
13+
s.dependency 'GoogleSignIn', '~> 5.0.2'
1414
s.static_framework = true
15-
end
15+
end

ios/Plugin.xcodeproj/project.pbxproj

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
/* Begin PBXBuildFile section */
1010
03FC29A292ACC40490383A1F /* Pods_Plugin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B2A61DA5A1F2DD4F959604D /* Pods_Plugin.framework */; };
11-
20C0B05DCFC8E3958A738AF2 /* Pods_PluginTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F6753A823D3815DB436415E3 /* Pods_PluginTests.framework */; };
11+
17AAD3396DA65BEB1CF90B13 /* Pods_PluginTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8D94D5F329B43669881B4B7D /* Pods_PluginTests.framework */; };
1212
50ADFF92201F53D600D50D53 /* Plugin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50ADFF88201F53D600D50D53 /* Plugin.framework */; };
1313
50ADFF97201F53D600D50D53 /* PluginTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50ADFF96201F53D600D50D53 /* PluginTests.swift */; };
1414
50ADFF99201F53D600D50D53 /* Plugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ADFF8B201F53D600D50D53 /* Plugin.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -39,10 +39,10 @@
3939
50ADFFA72020EE4F00D50D53 /* Plugin.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Plugin.m; sourceTree = "<group>"; };
4040
50E1A94720377CB70090CE1A /* Plugin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Plugin.swift; sourceTree = "<group>"; };
4141
5E23F77F099397094342571A /* Pods-Plugin.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Plugin.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Plugin/Pods-Plugin.debug.xcconfig"; sourceTree = "<group>"; };
42+
8D94D5F329B43669881B4B7D /* Pods_PluginTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_PluginTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4243
91781294A431A2A7CC6EB714 /* Pods-Plugin.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Plugin.release.xcconfig"; path = "Pods/Target Support Files/Pods-Plugin/Pods-Plugin.release.xcconfig"; sourceTree = "<group>"; };
43-
96ED1B6440D6672E406C8D19 /* Pods-PluginTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PluginTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests.debug.xcconfig"; sourceTree = "<group>"; };
44-
F65BB2953ECE002E1EF3E424 /* Pods-PluginTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PluginTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests.release.xcconfig"; sourceTree = "<group>"; };
45-
F6753A823D3815DB436415E3 /* Pods_PluginTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_PluginTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
44+
C5DBEB1C0497B6A0D0829A4E /* Pods-PluginTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PluginTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests.debug.xcconfig"; sourceTree = "<group>"; };
45+
E98DB64A6627A5A64318EF72 /* Pods-PluginTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PluginTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests.release.xcconfig"; sourceTree = "<group>"; };
4646
/* End PBXFileReference section */
4747

4848
/* Begin PBXFrameworksBuildPhase section */
@@ -60,7 +60,7 @@
6060
buildActionMask = 2147483647;
6161
files = (
6262
50ADFF92201F53D600D50D53 /* Plugin.framework in Frameworks */,
63-
20C0B05DCFC8E3958A738AF2 /* Pods_PluginTests.framework in Frameworks */,
63+
17AAD3396DA65BEB1CF90B13 /* Pods_PluginTests.framework in Frameworks */,
6464
);
6565
runOnlyForDeploymentPostprocessing = 0;
6666
};
@@ -112,8 +112,8 @@
112112
children = (
113113
5E23F77F099397094342571A /* Pods-Plugin.debug.xcconfig */,
114114
91781294A431A2A7CC6EB714 /* Pods-Plugin.release.xcconfig */,
115-
96ED1B6440D6672E406C8D19 /* Pods-PluginTests.debug.xcconfig */,
116-
F65BB2953ECE002E1EF3E424 /* Pods-PluginTests.release.xcconfig */,
115+
C5DBEB1C0497B6A0D0829A4E /* Pods-PluginTests.debug.xcconfig */,
116+
E98DB64A6627A5A64318EF72 /* Pods-PluginTests.release.xcconfig */,
117117
);
118118
name = Pods;
119119
sourceTree = "<group>";
@@ -123,7 +123,7 @@
123123
children = (
124124
50ADFFA52020D75100D50D53 /* Capacitor.framework */,
125125
3B2A61DA5A1F2DD4F959604D /* Pods_Plugin.framework */,
126-
F6753A823D3815DB436415E3 /* Pods_PluginTests.framework */,
126+
8D94D5F329B43669881B4B7D /* Pods_PluginTests.framework */,
127127
);
128128
name = Frameworks;
129129
sourceTree = "<group>";
@@ -166,12 +166,12 @@
166166
isa = PBXNativeTarget;
167167
buildConfigurationList = 50ADFF9F201F53D600D50D53 /* Build configuration list for PBXNativeTarget "PluginTests" */;
168168
buildPhases = (
169-
0596884F929ED6F1DE134961 /* [CP] Check Pods Manifest.lock */,
169+
2E4F6618F7BEADBB1427E0C0 /* [CP] Check Pods Manifest.lock */,
170170
50ADFF8D201F53D600D50D53 /* Sources */,
171171
50ADFF8E201F53D600D50D53 /* Frameworks */,
172172
50ADFF8F201F53D600D50D53 /* Resources */,
173-
CCA81D3B7E26D0D727D24C84 /* [CP] Embed Pods Frameworks */,
174-
DB1C8ED71F4EF74BC82B6234 /* [CP] Copy Pods Resources */,
173+
CDBD6291F99392856E80ED8A /* [CP] Embed Pods Frameworks */,
174+
954E831AAF3D05995C5AB46F /* [CP] Copy Pods Resources */,
175175
);
176176
buildRules = (
177177
);
@@ -240,16 +240,20 @@
240240
/* End PBXResourcesBuildPhase section */
241241

242242
/* Begin PBXShellScriptBuildPhase section */
243-
0596884F929ED6F1DE134961 /* [CP] Check Pods Manifest.lock */ = {
243+
2E4F6618F7BEADBB1427E0C0 /* [CP] Check Pods Manifest.lock */ = {
244244
isa = PBXShellScriptBuildPhase;
245245
buildActionMask = 2147483647;
246246
files = (
247247
);
248+
inputFileListPaths = (
249+
);
248250
inputPaths = (
249251
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
250252
"${PODS_ROOT}/Manifest.lock",
251253
);
252254
name = "[CP] Check Pods Manifest.lock";
255+
outputFileListPaths = (
256+
);
253257
outputPaths = (
254258
"$(DERIVED_FILE_DIR)/Pods-PluginTests-checkManifestLockResult.txt",
255259
);
@@ -258,6 +262,24 @@
258262
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
259263
showEnvVarsInLog = 0;
260264
};
265+
954E831AAF3D05995C5AB46F /* [CP] Copy Pods Resources */ = {
266+
isa = PBXShellScriptBuildPhase;
267+
buildActionMask = 2147483647;
268+
files = (
269+
);
270+
inputPaths = (
271+
"${PODS_ROOT}/Target Support Files/Pods-PluginTests/Pods-PluginTests-resources.sh",
272+
"${PODS_ROOT}/GoogleSignIn/Resources/GoogleSignIn.bundle",
273+
);
274+
name = "[CP] Copy Pods Resources";
275+
outputPaths = (
276+
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleSignIn.bundle",
277+
);
278+
runOnlyForDeploymentPostprocessing = 0;
279+
shellPath = /bin/sh;
280+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-PluginTests/Pods-PluginTests-resources.sh\"\n";
281+
showEnvVarsInLog = 0;
282+
};
261283
AB5B3E54B4E897F32C2279DA /* [CP] Check Pods Manifest.lock */ = {
262284
isa = PBXShellScriptBuildPhase;
263285
buildActionMask = 2147483647;
@@ -276,7 +298,7 @@
276298
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
277299
showEnvVarsInLog = 0;
278300
};
279-
CCA81D3B7E26D0D727D24C84 /* [CP] Embed Pods Frameworks */ = {
301+
CDBD6291F99392856E80ED8A /* [CP] Embed Pods Frameworks */ = {
280302
isa = PBXShellScriptBuildPhase;
281303
buildActionMask = 2147483647;
282304
files = (
@@ -285,15 +307,17 @@
285307
"${PODS_ROOT}/Target Support Files/Pods-PluginTests/Pods-PluginTests-frameworks.sh",
286308
"${BUILT_PRODUCTS_DIR}/Capacitor/Capacitor.framework",
287309
"${BUILT_PRODUCTS_DIR}/CapacitorCordova/Cordova.framework",
310+
"${BUILT_PRODUCTS_DIR}/AppAuth/AppAuth.framework",
311+
"${BUILT_PRODUCTS_DIR}/GTMAppAuth/GTMAppAuth.framework",
288312
"${BUILT_PRODUCTS_DIR}/GTMSessionFetcher/GTMSessionFetcher.framework",
289-
"${BUILT_PRODUCTS_DIR}/GoogleToolboxForMac/GoogleToolboxForMac.framework",
290313
);
291314
name = "[CP] Embed Pods Frameworks";
292315
outputPaths = (
293316
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Capacitor.framework",
294317
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cordova.framework",
318+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AppAuth.framework",
319+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GTMAppAuth.framework",
295320
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GTMSessionFetcher.framework",
296-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleToolboxForMac.framework",
297321
);
298322
runOnlyForDeploymentPostprocessing = 0;
299323
shellPath = /bin/sh;
@@ -305,15 +329,11 @@
305329
buildActionMask = 2147483647;
306330
files = (
307331
);
308-
inputFileListPaths = (
309-
);
310332
inputPaths = (
311333
"${PODS_ROOT}/Target Support Files/Pods-Plugin/Pods-Plugin-resources.sh",
312334
"${PODS_ROOT}/GoogleSignIn/Resources/GoogleSignIn.bundle",
313335
);
314336
name = "[CP] Copy Pods Resources";
315-
outputFileListPaths = (
316-
);
317337
outputPaths = (
318338
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleSignIn.bundle",
319339
);
@@ -322,28 +342,6 @@
322342
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Plugin/Pods-Plugin-resources.sh\"\n";
323343
showEnvVarsInLog = 0;
324344
};
325-
DB1C8ED71F4EF74BC82B6234 /* [CP] Copy Pods Resources */ = {
326-
isa = PBXShellScriptBuildPhase;
327-
buildActionMask = 2147483647;
328-
files = (
329-
);
330-
inputFileListPaths = (
331-
);
332-
inputPaths = (
333-
"${PODS_ROOT}/Target Support Files/Pods-PluginTests/Pods-PluginTests-resources.sh",
334-
"${PODS_ROOT}/GoogleSignIn/Resources/GoogleSignIn.bundle",
335-
);
336-
name = "[CP] Copy Pods Resources";
337-
outputFileListPaths = (
338-
);
339-
outputPaths = (
340-
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleSignIn.bundle",
341-
);
342-
runOnlyForDeploymentPostprocessing = 0;
343-
shellPath = /bin/sh;
344-
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-PluginTests/Pods-PluginTests-resources.sh\"\n";
345-
showEnvVarsInLog = 0;
346-
};
347345
/* End PBXShellScriptBuildPhase section */
348346

349347
/* Begin PBXSourcesBuildPhase section */
@@ -539,7 +537,7 @@
539537
};
540538
50ADFFA0201F53D600D50D53 /* Debug */ = {
541539
isa = XCBuildConfiguration;
542-
baseConfigurationReference = 96ED1B6440D6672E406C8D19 /* Pods-PluginTests.debug.xcconfig */;
540+
baseConfigurationReference = C5DBEB1C0497B6A0D0829A4E /* Pods-PluginTests.debug.xcconfig */;
543541
buildSettings = {
544542
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
545543
CODE_SIGN_STYLE = Automatic;
@@ -554,7 +552,7 @@
554552
};
555553
50ADFFA1201F53D600D50D53 /* Release */ = {
556554
isa = XCBuildConfiguration;
557-
baseConfigurationReference = F65BB2953ECE002E1EF3E424 /* Pods-PluginTests.release.xcconfig */;
555+
baseConfigurationReference = E98DB64A6627A5A64318EF72 /* Pods-PluginTests.release.xcconfig */;
558556
buildSettings = {
559557
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
560558
CODE_SIGN_STYLE = Automatic;

ios/Plugin/Plugin.swift

Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,54 +10,54 @@ import GoogleSignIn
1010
public class GoogleAuth: CAPPlugin {
1111
var signInCall: CAPPluginCall?
1212
let googleSignIn: GIDSignIn = GIDSignIn.sharedInstance();
13-
13+
1414
public override func load() {
1515
guard let path = Bundle.main.path(forResource: "GoogleService-Info", ofType: "plist") else {return}
1616
guard let dict = NSDictionary(contentsOfFile: path) as? [String: AnyObject] else {return}
1717
guard let clientId = dict["CLIENT_ID"] as? String else {return}
18-
18+
1919
googleSignIn.clientID = clientId;
2020
googleSignIn.delegate = self;
21-
googleSignIn.uiDelegate = self;
22-
21+
googleSignIn.presentingViewController = bridge.viewController;
22+
2323
if let serverClientId = getConfigValue("serverClientId") as? String {
2424
googleSignIn.serverClientID = serverClientId;
2525
}
26-
26+
2727
if let scopes = getConfigValue("scopes") as? [String] {
2828
googleSignIn.scopes = scopes;
2929
}
30-
30+
3131
NotificationCenter.default.addObserver(self, selector: #selector(handleOpenUrl(_ :)), name: Notification.Name(CAPNotifications.URLOpen.name()), object: nil);
3232
}
33-
33+
3434
@objc
3535
func signIn(_ call: CAPPluginCall) {
3636
signInCall = call;
37-
37+
3838
DispatchQueue.main.async {
39-
if self.googleSignIn.hasAuthInKeychain() {
40-
self.googleSignIn.signInSilently();
39+
if self.googleSignIn.hasPreviousSignIn() {
40+
self.googleSignIn.restorePreviousSignIn();
4141
} else {
4242
self.googleSignIn.signIn();
4343
}
4444
}
4545
}
46-
46+
4747
@objc
4848
func refresh(_ call: CAPPluginCall) {
4949
DispatchQueue.main.async {
5050
if self.googleSignIn.currentUser == nil {
5151
call.error("User not logged in.");
5252
return
5353
}
54-
54+
5555
self.googleSignIn.currentUser.authentication.getTokensWithHandler { (authentication, error) in
5656
guard let authentication = authentication else {
5757
call.error(error?.localizedDescription ?? "Something went wrong.");
5858
return;
5959
}
60-
60+
6161
let authenticationData: [String: Any] = [
6262
"accessToken": authentication.accessToken,
6363
"idToken": authentication.idToken,
@@ -75,28 +75,22 @@ public class GoogleAuth: CAPPlugin {
7575
}
7676
call.success();
7777
}
78-
78+
7979
@objc
8080
func handleOpenUrl(_ notification: Notification) {
8181
guard let object = notification.object as? [String: Any] else {
8282
print("There is no object on handleOpenUrl");
8383
return;
8484
}
85-
85+
8686
guard let url = object["url"] as? URL else {
8787
print("There is no url on handleOpenUrl");
8888
return;
8989
}
90-
91-
guard let options = object["options"] as? [UIApplication.OpenURLOptionsKey : Any] else {
92-
print("There is no options on handleOpenUrl");
93-
return;
94-
}
95-
96-
let sourceApplication = options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String;
97-
googleSignIn.handle(url, sourceApplication: sourceApplication, annotation: [:]);
90+
91+
googleSignIn.handle(url);
9892
}
99-
93+
10094
func processCallback(user: GIDGoogleUser) {
10195
var userData: [String: Any] = [
10296
"authentication": [
@@ -111,11 +105,11 @@ public class GoogleAuth: CAPPlugin {
111105
"id": user.userID,
112106
"name": user.profile.name
113107
];
114-
108+
115109
if let imageUrl = user.profile.imageURL(withDimension: 100)?.absoluteString {
116110
userData["imageUrl"] = imageUrl;
117111
}
118-
112+
119113
signInCall?.success(userData);
120114
}
121115
}
@@ -126,17 +120,7 @@ extension GoogleAuth: GIDSignInDelegate {
126120
signInCall?.error(error.localizedDescription);
127121
return;
128122
}
129-
130-
processCallback(user: user);
131-
}
132-
}
133123

134-
extension GoogleAuth: GIDSignInUIDelegate {
135-
public func sign(_ signIn: GIDSignIn!, present viewController: UIViewController!) {
136-
bridge.viewController.present(viewController, animated: true);
137-
}
138-
139-
public func sign(_ signIn: GIDSignIn!, dismiss viewController: UIViewController!) {
140-
viewController.dismiss(animated: true);
124+
processCallback(user: user);
141125
}
142126
}

ios/Podfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ target 'Plugin' do
66
pod 'Capacitor', :path => '../node_modules/@capacitor/ios'
77
pod 'CapacitorCordova', :path => '../node_modules/@capacitor/ios'
88

9-
pod 'GoogleSignIn', '< 5'
10-
9+
pod 'GoogleSignIn', '~> 5.0.2'
10+
1111
end
1212

1313
target 'PluginTests' do
1414
use_frameworks!
1515

1616
pod 'Capacitor', :path => '../node_modules/@capacitor/ios'
17-
end
17+
end

0 commit comments

Comments
 (0)