Skip to content

Commit 5d2165d

Browse files
author
Thibaud
authored
Fix line feed ios (#3) (#50)
Fix line feed ios for 2.1.1
1 parent a356225 commit 5d2165d

File tree

3 files changed

+10
-23
lines changed

3 files changed

+10
-23
lines changed

ios/Plugin/Plugin.swift

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Foundation
22
import Capacitor
33
import GoogleSignIn
4-
4+
55
/**
66
* Please read the Capacitor iOS Plugin Development Guide
77
* here: https://capacitor.ionicframework.com/docs/plugins/ios
@@ -16,30 +16,24 @@ public class GoogleAuth: CAPPlugin {
1616
guard let path = Bundle.main.path(forResource: "GoogleService-Info", ofType: "plist") else {return}
1717
guard let dict = NSDictionary(contentsOfFile: path) as? [String: AnyObject] else {return}
1818
guard let clientId = dict["CLIENT_ID"] as? String else {return}
19-
2019
googleSignIn.clientID = clientId;
2120
googleSignIn.delegate = self;
2221
googleSignIn.presentingViewController = bridge.viewController;
23-
2422
if let serverClientId = getConfigValue("serverClientId") as? String {
2523
googleSignIn.serverClientID = serverClientId;
2624
}
27-
2825
if let scopes = getConfigValue("scopes") as? [String] {
2926
googleSignIn.scopes = scopes;
3027
}
31-
3228
if let forceAuthCodeConfig = getConfigValue("forceCodeForRefreshToken") as? Bool {
3329
forceAuthCode = forceAuthCodeConfig;
3430
}
35-
3631
NotificationCenter.default.addObserver(self, selector: #selector(handleOpenUrl(_ :)), name: Notification.Name(CAPNotifications.URLOpen.name()), object: nil);
3732
}
38-
33+
3934
@objc
4035
func signIn(_ call: CAPPluginCall) {
4136
signInCall = call;
42-
4337
DispatchQueue.main.async {
4438
if self.googleSignIn.hasPreviousSignIn() && !self.forceAuthCode {
4539
self.googleSignIn.restorePreviousSignIn();
@@ -48,21 +42,19 @@ public class GoogleAuth: CAPPlugin {
4842
}
4943
}
5044
}
51-
45+
5246
@objc
5347
func refresh(_ call: CAPPluginCall) {
5448
DispatchQueue.main.async {
5549
if self.googleSignIn.currentUser == nil {
5650
call.error("User not logged in.");
5751
return
5852
}
59-
6053
self.googleSignIn.currentUser.authentication.getTokensWithHandler { (authentication, error) in
6154
guard let authentication = authentication else {
6255
call.error(error?.localizedDescription ?? "Something went wrong.");
6356
return;
6457
}
65-
6658
let authenticationData: [String: Any] = [
6759
"accessToken": authentication.accessToken,
6860
"idToken": authentication.idToken,
@@ -72,30 +64,28 @@ public class GoogleAuth: CAPPlugin {
7264
}
7365
}
7466
}
75-
67+
7668
@objc
7769
func signOut(_ call: CAPPluginCall) {
7870
DispatchQueue.main.async {
7971
self.googleSignIn.signOut();
8072
}
8173
call.success();
8274
}
83-
75+
8476
@objc
8577
func handleOpenUrl(_ notification: Notification) {
8678
guard let object = notification.object as? [String: Any] else {
8779
print("There is no object on handleOpenUrl");
8880
return;
8981
}
90-
9182
guard let url = object["url"] as? URL else {
9283
print("There is no url on handleOpenUrl");
9384
return;
9485
}
95-
9686
googleSignIn.handle(url);
9787
}
98-
88+
9989
func processCallback(user: GIDGoogleUser) {
10090
var userData: [String: Any] = [
10191
"authentication": [
@@ -110,22 +100,19 @@ public class GoogleAuth: CAPPlugin {
110100
"id": user.userID,
111101
"name": user.profile.name
112102
];
113-
114103
if let imageUrl = user.profile.imageURL(withDimension: 100)?.absoluteString {
115104
userData["imageUrl"] = imageUrl;
116105
}
117-
118106
signInCall?.success(userData);
119107
}
120108
}
121-
109+
122110
extension GoogleAuth: GIDSignInDelegate {
123111
public func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
124112
if let error = error {
125113
signInCall?.error(error.localizedDescription);
126114
return;
127115
}
128-
129116
processCallback(user: user);
130117
}
131-
}
118+
}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codetrix-studio/capacitor-google-auth",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "Google Auth plugin for capacitor.",
55
"main": "dist/esm/index.js",
66
"types": "dist/esm/index.d.ts",

0 commit comments

Comments
 (0)