Skip to content

mobilehero-archive/titanium-googlesignin

Repository files navigation

👇   support for Amplify Cloud and Mobile   👇

RIP Axway Amplify Titanium (2010 - 2022)

🪦   RIP Axway Amplify Titanium (2010 - 2022)

🪦   RIP Axway Amplify Cloud Services (2012 - 2022)

🪦   RIP Axway Amplify Crash Analytics (2015 - 2022)


🛑    Axway support for Amplify products has ended for most products related to mobile and cloud.

A few of the open-source versions of Axway Amplify products will live on after Axway Amplify End-of-Life (EOL) announcements. However, all closed-source projects and most open-source projects are now dead.

 

👉    A group of Axway employees, ex-Axway employees, and some developers from Titanium community have created a legal org and now officially decide all matters related to future of these products.

 


API FAQ:

 

Click to watch on Youtube

  ↑ Watch video on YouTube ↑

 

 


 

 

@titanium/googlesignin

@titanium/googlesignin Dependabot Status


📝 Description

Native modules that allows you to use the Google Sign-in SDK with Axway Titanium native mobile apps.

This is a repackaging of the compiled iOS module for ti.googlesignin to allow for installation via npm.

🚀 Getting Started

Install @titanium/googlesignin in root of project

npm install @titanium/googlesignin

Add required properties to iOS plist in tiapp.xml

<ti:app xmlns:ti="http://ti.appcelerator.org">
	<ios>
		<plist>
			<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>
		</plist>
	</ios>
</ti:app>

✨Features

  • Includes Titanium native iOS module: ti.googlesignin 3.0.0

Requirements

Example

This module was designed to follow a similar scheme like Ti.Facebook and Ti.GoogleSignIn.

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

google.initialize({
	clientID: 'xxxxxxxx-123456789.apps.googleusercontent.com',

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

google.addEventListener('login', e => {
	if (!e.success) {
		Ti.API.error(`Cannot login to Google: ${e.error}`);
		return;
	}

	const result = e.user;
	console.info('Logged in to Google!');
	// Do something with user result
});

google.addEventListener('logout', e => {
	console.info('Google Logged out / disconnected!');
});

// sign in
google.signIn();

// sign out
if (google.hasAuthInKeychain()) {
	google.disconnect();
}

APIs

Methods

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

Properties

  • language (String, get|set)
  • 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
  • cancel
  • load
  • open
  • close

The login- and logout events include a success flag as well as a user key that includes the following user-infos:

id, scopes, serverAuthCode, hostedDomain, profile, authentication

License

Apache 2.0

Authors

Hans Knöchel

📚Learn More

ti.googlesignin GitHub Repo - Repo for original ti.googlesignin module

📣 Feedback

Have an idea or a comment? Join in the conversation here!

©️ Legal

Modules are licensed under Apache 2.0 from https://github.com/appcelerator-modules/titanium-googlesignin

Alloy is developed by Appcelerator and the community and is Copyright © 2012-Present by Appcelerator, Inc. All Rights Reserved.

Alloy is made available under the Apache Public License, version 2. See their license file for more information.

Appcelerator is a registered trademark of Appcelerator, Inc. Titanium is a registered trademark of Appcelerator, Inc. Please see the LEGAL information about using trademarks, privacy policy, terms of usage and other legal information at http://www.appcelerator.com/legal.