Giter VIP home page Giter VIP logo

titanium-apple-sign-in's Introduction

iOS 13+ Apple Sign In in Titanium Build Status @titanium-sdk/ti.applesignin

Full support for iOS 13+ Apple Sign In with Titanium.

Requirements

The following project- and OS-requirements are necessary:

  • Xcode 11+
  • iOS 13+
  • Titanium SDK 8.0.0+

Example

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

var AppleSignIn = require('ti.applesignin');

AppleSignIn.addEventListener('login', function (event) {
  if (!event.success) {
    alert(event.error);
    return;
  }

  Ti.API.warn(event);
});

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

win.addEventListener('open', () => {
  AppleSignIn.checkExistingAccounts();
});

var btn = AppleSignIn.createLoginButton({ width: 280, height: 38 });

btn.addEventListener('click', function () {
  AppleSignIn.authorize();
});

win.add(btn);
win.open();

API's

Methods

checkExistingAccounts()

Checks for existing accounts (if available)

createLoginButton()

Creates a new localized login button.

authorize({ scopes })

Starts an authorization flow with an optional array of scoped. Defaults to all scopes (fullName and email).

getCredentialState(userId, callback)

Fetches the current credential state with a given user-id (received from the event.profile.userId key of the login event). The result is returned to the state parameter of the callback and can be authorized, revoked, transferred or unknown.

Events

login

The login event with the user's profile.

Installation

  • Add the following entitlements to your project:
<ios>
	<!-- ... -->
	
	<plist>
		<dict>
			<!-- ... -->
		</dict>
	</plist>
	
	<entitlements>
		<dict>
			<key>com.apple.developer.applesignin</key>
			<array>
				<string>Default</string>
			</array>
		</dict>
	</entitlements>
</ios>
  • Make sure your server is eligible to send mails to the Apple Sign In provider service.

License

MIT

Author

Hans Knöchel

titanium-apple-sign-in's People

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

Watchers

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

titanium-apple-sign-in's Issues

Mac support

Latest iOS version has no Mac support. Could this be added?

Email and name properties are missing from the returned profile object

When I'm trying to sign in with Apple on my test device (iPhone XS Max, iOS 13.7), I get userId and identityToken, but neither email address nor name.
It works fine on simulator (iPhone 8, iOS 13.3).
I tried to reset the device, but it didn't help.

I have a custom Apple button and I call authorize() method when clicking on it. And I have an attached event listener for login event.

My code:

AppleSignin = require('ti.applesignin');
AppleSignin.addEventListener('login', AppleLogin);

function appleClick(e) {
  AppleSignin.authorize({
    scopes: [
      AppleSignin.AUTHORIZATION_SCOPE_EMAIL,
      AppleSignin.AUTHORIZATION_SCOPE_FULLNAME
    ]
  });
}

function AppleLogin(e) {
  AppleSignin.removeEventListener('login', AppleLogin);
  if (e.success === true) {
    Ti.API.info(e.profile);
  } else {
    Ti.API.info('Apple login failed');
    Ti.API.info('Error: ' + JSON.stringify(e));
  }
}

Event login is fired and success === true, however the profile object does not contain neither email nor name. There is a name property actually which is an object, but every property is null.

The profile object:

{
  authorizationCode = "c8253....";
  authorizedScopes = (
  );
  identityToken = "eyJraWQi...";
  name = {
    firstName = "<null>";
    lastName = "<null>";
    middleName = "<null>";
    namePrefix = "<null>";
    nameSuffix = "<null>";
    nickname = "<null>";
  };
  realUserStatus = 1;
  state = "";
  userId = "0005...";
}

I'm using Mojave / Xcode 11, but I tried it on a Catalina VBox guest machine with the latest Xcode 12, but the result was the same.

Any suggestion would be helpful :)

We have noticed that only the first time returns user's info name and email.

We have noticed that only the first time returns user's info name and email.

If you try to re-call you get the following:

authorizedScopes = ()

name = {
      firstName = "<null>";
      lastName = "<null>";
      middleName = "<null>";
      namePrefix = "<null>";
      nameSuffix = "<null>";
      nickname = "<null>";
};

Could you please help?

AppleSignin.authorize() produces an OK alert dialog instead of showing apple sign in screen

Hi,
 
We are getting an issue with apple sign in. AppleSignin.authorize() produces an OK alert dialog instead of showing apple sign in screen. Can you please help?
 
Below are some details:
 
To integrate apple sign we performed the following steps.
 

  1. Installed the ti.applesignin module
     
  2. Added the entitlement section to tiapp.xml

 
     
        com.apple.developer.applesignin
       
          Default
       
     
   

  1.  added the following code

var AppleSignIn = require('ti.applesignin');
 
AppleSignIn.addEventListener('login', function (event) {
 Ti.API.warn(event.error);
 console.warn(loginevent: ${JSON.stringify(event, null, 2)});
 if (!event.success) {
   alert(event.error);
   return;
 }
 
  Ti.API.warn(event);
});
 
var win = Ti.UI.createWindow({
  backgroundColor: '#fff'
});
 
var btn = AppleSignIn.createLoginButton({ width: 280, height: 38 });
 
btn.addEventListener('click', function () {
  AppleSignIn.authorize();
});
 
win.add(btn);
win.open();  

  1. Enabled the sign in option in provisioning profile on https://developer.apple.com/ and downloaded and installed that provisioning profile to run our app.
     
    Titanium SDK version: 8.3.0
     
    The "Sign In" button shows up but on clicking it gives only ‘OK’.
     
    The event object logs show success: false and cancelled: true and there is no error field (see log below):
     
    loginevent: {
    [WARN] :     "success": false,
    [WARN] :     "cancelled": true,
    [WARN] :     "bubbles": true,
    [WARN] :     "type": "login",
    [WARN] :     "source": {},
    [WARN] :     "cancelBubble": false
    [WARN] :   }

apple sign in module not returning userid on login event

Hi,

I am trying to get the userid and other details from apple sign in the module but its returning following details. am I missing something?

event: {"cancelled":true,"success":false,"bubbles":true,"type":"login","source":{},"cancelBubble":false}

tiapp.xml details
SDK: 8.2.1
tried with developer certificate and Adhoc certificate too but no success.
created identifiers too but nothing seems to work.

Do I have to add a domain as well? there was an option to create Service ID and domain configuration?

Please help with more details.

Thanks in advance! :)

Error when calling AppleSignIn.authorize()

iOS 13 GM
SDK 8.2.0.RC
Xcode 11 GM

Using the sample code provided:

var AppleSignIn = require('ti.applesignin');

AppleSignIn.addEventListener('login', function (event) {
  if (!event.success) {
    alert(event.error);
    return;
  }

  Ti.API.warn(event);
});

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

var btn = AppleSignIn.createLoginButton({ width: 280, height: 38 });

btn.addEventListener('click', function () {
  AppleSignIn.authorize();
});

win.add(btn);
win.open();

I am getting an error:

The operation couldn’t be completed. 
(com.apple.AuthenticationServices.AuthorizationError error 1000.

The function AppleSignIn.authorize() is immediately triggering the login event where the error is the caught.

IMG_3338

AppleSignin.authorize produce a OK alert dialog

With Titanium SDK 8.2.1, iOS 13.1.3

Calling AppleSignIn.authorize produces a UIAlertDialog with a OK message. Nothing happens from there.

Appcelerator console shows:
[ERROR] : UIAlertController is up and showing an alert. ABORTING showing of modal controller

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.