Giter Site home page Giter Site logo

hansemannn / titanium-google-signin Goto Github PK

View Code? Open in Web Editor NEW
30.0 11.0 16.0 88.56 MB

Use the native Google Sign In SDK in Appcelerator Titanium.

License: Other

JavaScript 0.46% Objective-C 98.31% Kotlin 0.62% C 0.61%
google-signin titanium native javascript ios-sdk android-sdk

titanium-google-signin's Introduction

Google SignIn SDK in Appcelerator Titanium

Google SignIn

Summary

Ti.GoogleSignIn is an open-source project to support the Google SignIn SDK in Appcelerator's Titanium.

Requirements

  • Titanium SDK 9.2.0+
  • Ti.PlayServices (Android)

Download

Releases page

Setup

iOS Setup

Add the following URL types to your plist section of the tiapp.xml:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLName</key>
        <string>google</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <!-- Example: com.googleusercontent.apps.123456789-xxxxxxxx -->
            <string>YOUR_REVERSE_CLIENT_ID</string>
        </array>
    </dict>
</array>

Android Setup

The Android setup is made possible by the excellent work from chmiiller and AppWerft in the Ti.GoogleSignIn repository. Thank you!

Permissions in manifest
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
⚠️ PLEASE NOTE!

You will need to use the Web ClientID from Google instead of an Android one.

Google Play Console

Obtaining a SHA-1 with Titanium

In order to use Google Sign In in your app you will need to provide an SHA-1 certificate fingerprint for Google Console. You will need to provide a debug and a distribution SHA-1 fingerprint for your app. On Titanium, the debug SHA-1 has to be generated from the dev_keystore file from your Titanium SDK android folder located at "mobilesdk//<sdk_version>/android/dev_keystore". On macOS for example it would rely on: "~/Library/Application\ Support/Titanium/mobilesdk/osx/9.3.0.GA/android/dev_keystore".
And an command line example for it would be:

keytool -list -v -keystore ~/Library/Application\ Support/Titanium/mobilesdk/osx/9.3.0.GA/android/dev_keystore

You can follow same instructions used to configure a map in your Android app from Appcelerator Docs.

This repo also includes a video on how to create an Android app on Firebase and Google Developers Console to better explain the process.
As Appcelerator's documentation recommends, when submitting your app to Google Play Store you will need to create a production .keystore file, so don't forget to create another SHA-1 for this key and remember to add it also as another "fingerprint" on Firebase.
Note that some users have reported problems when submitting new apps to the Play Store, where the Google Login stop working on production. A solution found was to get another SHA-1 fingerprint from the Google Play app's dashboard and add this fingerprint to Firebase. These fingerprints could be found on your Google Play Console, under the "Release Management" menu on the left and then on "App signing". Here is an example on how it looks like:
Google Play Console

Example

Initialize the module by setting the Google SignIn API key you can get from the Google API Console.

import GoogleSignIn from 'ti.googlesignin';

GoogleSignIn.initialize({
    // Required properties
    clientID: '<client-id>',

    // Optional properties:
    serverClientID: '<server-client-id>',
    scopes: ['https://www.googleapis.com/auth/plus.login'], // See https://developers.google.com/identity/protocols/googlescopes for more
    loginHint: 'Titanium rocks!',
    hostedDomain: 'https://my-hosted-domain.com',
    openIDRealm: 'my-openID-realm',
});

Methods

  • signIn()
  • signInSilently()
  • signOut()
  • disconnect()
  • hasAuthInKeychain -> Boolean
  • currentUserImageURLWithSize(size) -> String (iOS only)

Properties

  • language (String, get|set, iOS, only)
  • currentUser (Dictionary, get)
    • id (String) 
    • scopes (Array) 
    • serverAuthCode (String) 
    • hostedDomain (String) 
    • profile (Dictionary)
      • name (String)
      • givenName (String)
      • familyName (String)
      • email (String)
      • hasImage (Boolean)
    • authentication (Dictionary)
      • clientID (String)
      • accessToken (String)
      • accessTokenExpirationDate (Date)
      • refreshToken (String)
      • idToken (String)
      • idTokenExpirationDate (Date)

Events

  • login
  • logout

The login event also includes the current user via the user property.

Build

If you want to build the module from the source, you need to check some things beforehand:

  • Set the TITANIUM_SDK_VERSION inside the ios/titanium.xcconfig file to the Ti.SDK version you want to build with.
  • Build the project with appc run -p ios --build-only
  • Check the releases tab for stable pre-packaged versions of the module

Example

For a basic example, check the demo in example/app.js. For a full sample-app, check out the demo in example/sample-app.

Author

Hans Knoechel (@hansemannnn / Web)

License

Apache 2.0

Contributing

Code contributions are greatly appreciated, please submit a new pull request!

titanium-google-signin's People

Contributors

hansemannn avatar m1ga avatar qaqee-dk avatar xalfeiran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

titanium-google-signin's Issues

NSInvalidArgumentException when user clicks on "Done" button

Hi @hansemannn ,
first of all thanks for the module! It works perfectly on iOS.
Feels 100% native, easy setup, instructions, documentation and retrieves needed information from the user.
The only thing is that the app is crashing when you click the "Done" button on Top Left corner.
The error message is:

The application has crashed with an uncaught exception 'NSInvalidArgumentException'.
Reason:
*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]
Stack trace:
CoreFoundation -> __exceptionPreprocess + 147

libobjc.A.dylib -> objc_exception_throw + 48

CoreFoundation -> -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 351

CoreFoundation -> +[NSDictionary dictionaryWithObjects:forKeys:count:] + 59

building -> +[TiGooglesigninModule dictionaryFromUser:] + 823

building -> -[TiGooglesigninModule signIn:didSignInForUser:withError:] + 115

building -> -[GIDSignIn safariViewControllerDidFinish:] + 129

SafariServices -> -[SFSafariViewController remoteViewControllerWillDismiss:] + 128

SafariServices -> -[SFBrowserRemoteViewController willDismissServiceViewController] + 47

CoreFoundation -> __invoking___ + 140

CoreFoundation -> -[NSInvocation invoke] + 289

FrontBoardServices -> __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24

FrontBoardServices -> -[FBSSerialQueue _performNext] + 189

FrontBoardServices -> -[FBSSerialQueue _performNextFromRunLoopSource] + 45

CoreFoundation -> __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17

CoreFoundation -> __CFRunLoopDoSources0 + 556

CoreFoundation -> __CFRunLoopRun + 918

CoreFoundation -> CFRunLoopRunSpecific + 420

GraphicsServices -> GSEventRunModal + 161

UIKit -> UIApplicationMain + 159

building -> main + 100

libdyld.dylib -> start + 1

??? -> 0x0 + 1

Do you have any clue?

My Configurations:
Ti SDK: 6.0.1.GA
iOS: 10.2.1
Development build
Also crashing on Simulator =/

Thanks again! 😁

currentUserImageURLWithSize doesn't work: Invalid type passed to function

Hi @hansemannn ,
I'm getting:

"nativeLocation": "-[TiGooglesigninModule currentUserImageURLWithSize:] (TiGooglesigninModule.m:171)",
  "message": "Invalid type passed to function",
  "nativeReason": "expected: Number, was: Array",

when using:

var profileURL = Google.currentUserImageURLWithSize(200);

The problem is happening on this line on TiGooglesigninModule.m, line 173:

return [[[[[GIDSignIn sharedInstance] currentUser] profile] imageURLWithDimension:[TiUtils intValue:size]] absoluteString];

Noticed that you're using ENSURE_TYPE(size, NSNumber); but can't understand why it is complaining that we're passing an array instead of a number.
Can you think in a reason for that?

Thanks!

Must use Apple SSO if using Google SSO

Hi,

We are going to be implementing Google SSO with the modules here (works great) however we came across an Apple guideline that may or may not have been available at the time this module was created -- stating

"4.8 Sign in with Apple
Apps that use a third-party or social login service (such as Facebook Login, Google Sign-In, Sign in with Twitter, Sign In with LinkedIn, Login with Amazon, or WeChat Login) to set up or authenticate the user’s primary account with the app must also offer Sign in with Apple as an equivalent option."

https://developer.apple.com/app-store/review/guidelines/#sign-in-with-apple

Might be helpful if this was in the read me of this repo to prevent any rejected submissions, not sure if anyone using this module has had any issues with submissions when only including Google SSO.

Thanks,
Eric

Your app is missing support

Hey Hans, please help me with this issue.

Your app is missing support for the following URL schemes: com.googleusercontent.apps.127078586633-vfcjhebv09887vbm4651l983aqffu2hq

I got CLIENT_ID and REVERSED_CLIENT_ID from GoogleService-Info file

CLIENT_ID :
127078586633-vfcjhebv09887vbm4651l983aqffu2hq.apps.googleusercontent.com
REVERSED_CLIENT_ID :
com.googleusercontent.apps.127078586633-vfcjhebv09887vbm4651l983aqffu2hq

and added the CLIENT_ID in google.initialize and REVERSED_CLIENT_ID in CFBundleURLSchemes.

Android version

Hi, is there an Android version expected soon?

Or is there an android equivalent, can't seem to find one anywhere and struggling to create one.

Keychain Error

Getting this error: Login UI errored: keychain error

when I try to invoke Google.signIn(); - anything I'm missing here? On 6.3.0 on the simulator pushing to 11.1.

Thanks!
Jared

(I tried everything recommended here: benbahrenburg/Securely#48 to no avail)

Change language after module initialization

First thanks for providing such a wonderful module for Titanium community 👍👍
I've noticed that we can specify a desired language when invoking initialize method. But would it be possible to add a separate method to enable changing the language again afterwards? This can be helpful for apps supporting multiple languages~

Missing support for URL schemes error

Hi. I'm experiencing problems with this module. The error is the following:

Your app is missing support for the following URL schemes: com.googleusercontent.apps..***************-xxxxxxxx

...but I added the scheme correctly in tiapp.xml:

<key>CFBundleURLTypes</key>
<array>
  <dict>
      <key>CFBundleTypeRole</key>
      <string>Editor</string>
      <key>CFBundleURLName</key>
      <string>google</string>
      <key>CFBundleURLSchemes</key>
      <array>
	  <string>com.googleusercontent.apps.***************-xxxxxxxx</string>
      </array>
  </dict>
</array>

I also added it in LSApplicationQueriesSchemes (https://stackoverflow.com/questions/30987986/ios-9-not-opening-instagram-app-with-url-scheme).

Could you help me to find the source of the problem? Any help will be appreciated, Thanks in advance!

Best regards

Conflict with ti.map 3.1.1

After i added then build it error conflict with ti.map.
Please help me. i try find but no solution on it. (SDK 6.0.3)

[ERROR] : Failed to run dexer:
[ERROR] :
[ERROR] : UNEXPECTED TOP-LEVEL EXCEPTION:
[ERROR] : java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/auth/api/signin/internal/zze;
[ERROR] : at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
[ERROR] : at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
[ERROR] : at com.android.dx.command.dexer.Main.processClass(Main.java:732)
[ERROR] : at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
[ERROR] : at com.android.dx.command.dexer.Main.access$300(Main.java:83)
[ERROR] : at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
[ERROR] : at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
[ERROR] : at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
[ERROR] : at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
[ERROR] : at com.android.dx.command.dexer.Main.processOne(Main.java:632)
[ERROR] : at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
[ERROR] : at com.android.dx.command.dexer.Main.runMultiDex(Main.java:334)
[ERROR] : at com.android.dx.command.dexer.Main.run(Main.java:244)
[ERROR] : at com.android.dx.command.dexer.Main.main(Main.java:215)
[ERROR] : at com.android.dx.command.Main.main(Main.java:106)
[ERROR] :
[ERROR] : UNEXPECTED TOP-LEVEL EXCEPTION:
[ERROR] : java.lang.IllegalArgumentException: already added: Lcom/google/firebase/FirebaseApiNotAvailableException;
[ERROR] : at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
[ERROR] : at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
[ERROR] : at com.android.dx.command.dexer.Main.processClass(Main.java:732)
[ERROR] : at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
[ERROR] : at com.android.dx.command.dexer.Main.access$300(Main.java:83)
[ERROR] : at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
[ERROR] : at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
[ERROR] : at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
[ERROR] : at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
[ERROR] : at com.android.dx.command.dexer.Main.processOne(Main.java:632)
[ERROR] : at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
[ERROR] : at com.android.dx.command.dexer.Main.runMultiDex(Main.java:334)
[ERROR] : at com.android.dx.command.dexer.Main.run(Main.java:244)
[ERROR] : at com.android.dx.command.dexer.Main.main(Main.java:215)
[ERROR] : at com.android.dx.command.Main.main(Main.java:106)
[ERROR] : 2 errors; aborting

libti.googlesignin.a

I tried to compile the app after adding the module and I got the following error:

[ERROR] : Module ti.googlesignin version 1.1.3 is missing library file: /Users/jatinjoshi/Documents/Appcelerator_Studio_Workspace/RailGuard/modules/iphone/ti.googlesignin/iphone/libti.googlesignin.a

Build Failed with the module

Hi,
I can't build when including the module in tiapp.xml
I get the following error:
Ld build/Products/Debug-iphonesimulator/ShoutOut.app/ShoutOut normal x86_64

Maybe it's related to the fact that CLI update (Appcelerator CLI 6.2.3.GA ) is failing?

This is the CLI update fail error:
Error encountered during update
Failed to get value of npm config key prefix: module.js:327
throw err;
^

Error: Cannot find module 'semver'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (/usr/local/lib/node_modules/npm/lib/utils/unsupported.js:2:14)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)

Anyway, all other modules are built well

I will appreciate a quick help

Rony

Failed to build project with this module

When trying to load sample project received following error:

[TRACE] : Undefined symbols for architecture x86_64:
[TRACE] : "_OBJC_CLASS_$_LAContext", referenced from:
[TRACE] : objc-class-ref in GoogleSignIn(MDMPasscodeCache_42de90102bb6814d03833694aafcc99d.o)
[TRACE] : ld: symbol(s) not found for architecture x86_64
[TRACE] : clang
[TRACE] : : error: linker command failed with exit code 1 (use -v to see invocation)
[ERROR] : ** BUILD FAILED **
[ERROR] : The following build commands failed:
[ERROR] : Ld /Users/qalbit/Documents/axway_ws/FatShares-App/build/iphone/build/Products/Debug-iphonesimulator/FatShares.app/FatShares normal x86_64 [ERROR] : (1 failure)

Error while sign in

Module giving me an error while Google.signIn()

[ERROR] : Script Error {
[ERROR] : column = 15;
[ERROR] : line = 171;
[ERROR] : message = "Your app is missing support for the following URL schemes: "MY_CLIENT_ID";
[ERROR] : stack = "[native code]\n";
[ERROR] : }

is there any solution for this?

Google sign out

Hans-

Thanks for this great module. How would I go about keeping a user signed-out? What I'm wanting is to force the user to sign-in and enter their password again after calling the disconnect() method? Currently, they can re-authenticate without entering their password if you call disconnect() and then signIn().

Any input would be appreciated.

not building together with firebase Module(iOS)

Hi,
I have added this two module in My Appcelerator project. But My appcelerator not build with this module.

If I added both module individually then it building properly . but added two module in single project cause me a issue.

[ERROR] : ** BUILD FAILED **

[ERROR] : The following build commands failed:

[ERROR] : Ld /Users/admin/Documents/Appcelerator_Studio_Workspace/testt/build/iphone/build/Products/Debug-iphonesimulator/testt.app/testt normal x86_64

[ERROR] : (1 failure)

Link for both module are
screenshot 2019-02-11 at 4 38 09 pm

400 invalid_request

Getting Error 400.
Error : invalid_request
Custom scheme URIs are not allowed for "Web" client type.

My entry in tiapp.xml

**<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>google</string>
<key>CFBundleURLSchemes</key>
<array>
		<string>com.googleusercontent.apps.*******************</string>
</array>**

simulator screen shot - iphone 7 - 2018-05-12 at 23 41 38

Making it build with Xcode 11 and Titanium SDK 8.2.0

An issue with Objective-C modules disabled, prevented to build in Xcode 11.

Changed settings to Enable Modules (C and Objective-C) to Yes

voila!

tried again
appc ti build -p ios --build-only
and it works with Titanium 8.2.0.GA

Error accesing currentUser

trying to access currentUser after a successful login fires the following error.

[ERROR] The application has crashed with an uncaught exception 'NSInvalidArgumentException'.
[ERROR] Reason:
[ERROR] *** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]
[ERROR] Stack trace:
[ERROR] 0   CoreFoundation                      0x000000010b2c31bb __exceptionPreprocess + 331
[ERROR] 1   libobjc.A.dylib                     0x000000010a0be735 objc_exception_throw + 48
[ERROR] 2   CoreFoundation                      0x000000010b20f4ec _CFThrowFormattedException + 194
[ERROR] 3   CoreFoundation                      0x000000010b332541 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 321
[ERROR] 4   CoreFoundation                      0x000000010b2bec9b +[NSDictionary dictionaryWithObjects:forKeys:count:] + 59
[ERROR] 5   test-app                               0x000000010455f187 +[TiGooglesigninModule dictionaryFromUser:] + 792
[ERROR] 6   test-app                               0x000000010455e57a -[TiGooglesigninModule currentUser] + 150
[ERROR] 7   test-app                               0x000000010425bcef -[KrollObject _valueForKey:] + 3007
[ERROR] 8   test-app                               0x000000010425c856 -[KrollObject valueForKey:] + 406
[ERROR] 9   test-app                               0x00000001042590e1 KrollHasProperty + 321
[ERROR] 10  JavaScriptCore                      0x00000001049fa1f1 _ZN3JSC16JSCallbackObjectINS_20JSDestructibleObjectEE18getOwnPropertySlotEPNS_8JSObjectEPNS_9ExecStateENS_12PropertyNameERNS_12PropertySlotE + 353
[ERROR] 11  JavaScriptCore                      0x0000000104f8283a llint_slow_path_get_by_id + 3018
[ERROR] 12  JavaScriptCore                      0x00000001049c979d llint_entry + 11553
[ERROR] 13  JavaScriptCore                      0x00000001049c68fe vmEntryToJavaScript + 244
[ERROR] 14  JavaScriptCore                      0x0000000104ec2846 _ZN3JSC11Interpreter11executeCallEPNS_9ExecStateEPNS_8JSObjectENS_8CallTypeERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 470
[ERROR] 15  JavaScriptCore                      0x00000001050c39b4 _ZN3JSC12profiledCallEPNS_9ExecStateENS_15ProfilingReasonENS_7JSValueENS_8CallTypeERKNS_8CallDataES3_RKNS_7ArgListE + 196
[ERROR] 16  JavaScriptCore                      0x0000000104a062d4 JSObjectCallAsFunction + 468
[ERROR] 17  JavaScriptCore                      0x00000001049d9bc3 -[JSValue callWithArguments:] + 291
[ERROR] 18  test-app                               0x0000000104252b97 -[KrollTimerTarget timerFired:] + 87
[ERROR] 19  Foundation                          0x00000001069d3881 __NSFireTimer + 83
[ERROR] 20  CoreFoundation                      0x000000010b228f34 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
[ERROR] 21  CoreFoundation                      0x000000010b228b32 __CFRunLoopDoTimer + 1026
[ERROR] 22  CoreFoundation                      0x000000010b22839a __CFRunLoopDoTimers + 266
[ERROR] 23  CoreFoundation                      0x000000010b222a1c __CFRunLoopRun + 2252
[ERROR] 24  CoreFoundation                      0x000000010b221e11 CFRunLoopRunSpecific + 625
[ERROR] 25  GraphicsServices                    0x0000000110d921dd GSEventRunModal + 62
[ERROR] 26  UIKitCore                           0x000000011836081d UIApplicationMain + 140
[ERROR] 27  test-app                               0x00000001042358d3 main + 115
[ERROR] 28  libdyld.dylib                       0x000000010c848575 start + 1

Architectures not found. arm67

Downloaded the stable version of the module on iphoneX ios 11

[INFO] : Ti.Platform.name : iPhone OS
[ERROR] : Script Error Couldn't find module: ti.googlesignin for architecture: arm64

Main thread

I think signIn and signInSilently methods should be called from main thread, to avoid Google Sign-in instance issues (such as after an app restart). I had several problems with that. One is reported here: googlesamples/google-services#108
I'll add a code later.

Daniel

Can't login

simulator screen shot - iphone 5s - 2018-02-13 at 14 45 35

const Google = require('ti.googlesignin');

  Google.initialize({
    clientID: Alloy.CFG.Google.SignIn // -> 789544906850-xxxxxxx.apps.googleusercontent.com

    // Optional properties:
    , scopes: ['https://www.googleapis.com/auth/plus.login'] // See https://developers.google.com/identity/protocols/googlescopes for more
    , language: 'pt-BR' // Or 'de-DE', 'en-US', etc.
    , loginHint: 'Titanium rocks!'
  });

I'm using Web Client ID as clientID as mentioned on Android's module version

500. That's an error

On IOS I'm using:
Ti SDK : 7.2.0.GA
ti.playservices : 11.0.40
hyperloop : 3.0.5
ti.googlesignin : 1.3.0
Alloy project

index.js

var Google = require('ti.googlesignin');

Google.initialize({
 clientID : "299110198604-ng3jja5uqg7fleo3i8hsu7mitgu3iu2v.apps.googleusercontent.com",
});

var loggedIn = Google.hasAuthInKeychain();
var logOutMessage = 'Sign Out';
var logInMessage = 'Sign In with Google';

var win = Ti.UI.createWindow({
    backgroundColor: '#fff'
});

var scroll = Ti.UI.createScrollView({
    top: 40,
    layout: 'vertical'
});
win.add(scroll);

var btn = Ti.UI.createButton({
    title: loggedIn ? logOutMessage : logInMessage,
});

Google.addEventListener('login', function(e) {
    Ti.API.info('Logged in!');
    Ti.API.info(e.user);

    idLabel.text = 'id: ' + e.user.id;
    nameLabel.text = 'name: ' + e.user.profile.name;
    emailLabel.text = 'email: ' + e.user.profile.email;

    if (e.user.profile.hasImage) {
        profilePicture.visible = true;
        profilePicture.height = 100;
        profilePicture.setImage(Google.currentUserImageURLWithSize(200));
    }

    loggedIn = true;
    updateButtonState();
});

Google.addEventListener('disconnect', function(e) {
    Ti.API.info('Disconnected!'); // The Google SignIn API prefers "diconnect" over "logout"
    Ti.API.info(e.user);

    idLabel.text = '';
    nameLabel.text = '';
    emailLabel.text = '';
    profilePicture.visible = false;
    profilePicture.height = 0;

    loggedIn = false;
    updateButtonState();
});

Google.addEventListener('load', function(e) {
    Ti.API.info('Login UI loaded!');
});

Google.addEventListener('cancel', function(e) {
    Ti.API.info('Login UI cancelled: ' + e.message);
});

Google.addEventListener('error', function(e) {
    Ti.API.info('Login UI errored: ' + e.message);
});

Google.addEventListener('open', function(e) {
    Ti.API.info('Login UI opened!');
});

Google.addEventListener('close', function(e) {
    Ti.API.info('Login UI closed!');
});

btn.addEventListener('click', function() {
    if (loggedIn) {
        Google.disconnect();
    } else {
        Google.signIn();
    }
});

function updateButtonState() {
    btn.setTitle(loggedIn ? logOutMessage : logInMessage)
    btn.width = Ti.UI.SIZE;
}

scroll.add(btn);

var profilePicture = Ti.UI.createImageView({
    width: 100,
    height: 100,
    top: 20,
    borderRadius: 50
});
scroll.add(profilePicture);

var idLabel = Ti.UI.createLabel({
    color: 'black',
    font: {
        fontSize: 18
    },
    top: 20,
    left: 20,
    text: ''
});
scroll.add(idLabel);


var nameLabel = Ti.UI.createLabel({
    color: 'black',
    font: {
        fontSize: 18
    },
    top: 20,
    left: 20,
    text: ''
});
scroll.add(nameLabel);

var emailLabel = Ti.UI.createLabel({
    color: 'black',
    font: {
        fontSize: 18
    },
    top: 20,
    left: 20,
    text: ''
});
scroll.add(emailLabel);

win.open();

i am runing above code on IOS simulator it given following error:

simulator screen shot - iphone 6 - 2018-08-17 at 15 16 48

Cannot get iOS app to build with googlelSignin module

I am currently using Ti SDK 9.3.2 and xCode 12.4 and Firebase Core 6.1.1 module installed for my project. I have downloaded ti.googlesignin for iOS version 4.1.0 and 4.2.0. Whenever I try to compile the app with the module reference in the tiapp.xml file, the compile fails with the following error when setting log-level to trace. If I remove the module reference, the app compiles properly.

[TRACE] ld: warning: directory not found for option '-L/Users/user/Documents/myapp/build/iphone/lib' [TRACE] ld: warning: ignoring file /Users/user/Documents/myapp/build/iphone/build/Products/Debug-iphonesimulator/libti.googlesignin.a, building for iOS Simulator-i386 but attempting to link with file built for iOS Simulator-x86_64 [TRACE] ld: warning: ignoring file /Users/user/Documents/myapp/build/iphone/build/Products/Debug-iphonesimulator/libfirebase.core.a, missing required architecture i386 in file /Users/user/Documents/myapp/build/iphone/build/Products/Debug-iphonesimulator/libfirebase.core.a (2 slices) [TRACE] ld: warning: Could not find or use auto-linked framework 'FBLPromises' [TRACE] Undefined symbols for architecture i386: [TRACE] "_OBJC_CLASS_$_LAContext", referenced from: [TRACE] objc-class-ref in GoogleSignIn(MDMPasscodeCache_9db9a55228f5f3452187a7c521fe0062.o) [TRACE] ld: symbol(s) not found for architecture i386 [TRACE] clang: error: linker command failed with exit code 1 (use -v to see invocation) [ERROR] ** BUILD FAILED **

Any idea what might be going on?

Scopes and permissions

It's not clear how to properly use/add scopes after the 5.0.0 breaking change/deprecation. README.md still shows to keep using them as an object on GoogleSignIn.initialize, however, scopes there are flagged as removed and they are not recognized: they don't return as valid granted scopes.

GoogleSignIn.initialize({
    clientID: '<client-id>',
    scopes: ['https://www.googleapis.com/auth/drive.file']
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.