Ti.GoogleSignIn is an open-source project to support the Google SignIn iOS-SDK in Appcelerator's Titanium Mobile.
- Titanium Mobile SDK 5.5.1.GA or later
- iOS 7.1 or later
- Xcode 7.3 or later
Unpack the module and place it inside the modules/iphone/
folder of your project.
Edit the modules section of your tiapp.xml
file to include this module:
<modules>
<module platform="iphone">ti.googlesignin</module>
</modules>
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>
Initialize the module by setting the Google SignIn API key you can get from the Google API Console.
var Google = require('ti.googlesignin');
Google.initialize({
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
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',
});
-
signIn
-
signInSilently
-
signOut
-
disconnect
-
hasAuthInKeychain
-
currentUserImageURLWithSize
-
currentUser
-
login
-
disconnect
-
cancel
-
error
-
load
-
open
-
close
The login
- and disconnect
events include a user
key that includes the following user-infos:
id, scopes, serverAuthCode, hostedDomain, profile, authentication
If you want to build the module from the source, you need to check some things beforehand:
- Set the
TITANIUM_SDK_VERSION
inside theios/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
TBA
For a full example, check the demo in example/app.js
.
Hans Knoechel (@hansemannnn / Web)
Apache 2.0
Code contributions are greatly appreciated, please submit a new pull request!