Titanium Appcelerator Quickie: Cocoafish Native Module + Facebook Integration - Clearly Innovative | Web and Mobile DevelopmentClearly Innovative | Web and Mobile Development

This is a continuation of the series of blog posting we have been doing on CocoaFish.

Please take a look at the earlier postings Titanium Appcelerator Quickie: Cocoafish Native iOS Module and Titanium Appcelerator Quickie: Cocoafish API Module and the slide deck here explaining why I think platforms like CocoaFish are important in mobile development

   AND     

Creating An Account with Facebook

The external account login will create a Cocoafish account if it hasn’t been created, otherwise, it will login using the user who has the matching external account info.

Here is where you call the cocoafish API; but as you can see it has the standard Appcelerator Facebook login code. This is how you get the user’s Facebook Access Token which is required to login with the account

We also have the actual function that call CocoaFish API to link the two accounts, that code in wrapped in the function loginWithFacebook

If it worked, you should see this when you look at the users account information in the console

Inside of loginWithFacebook, we use the facebook uid to log in and/or create an account in CocoaFish.

Unlinking Account From Facebook

Unlinking the account from facebook is pretty straight forward. Just use the Facebook UID from the user and make the API call.

You might need to either login or ensure you have the Titanium.Facebook.uid or you could have saved it from the user’s account.

All the external account information is accessible from the CocoaFish user object, see listing of external accounts above.

See the module and complete documentation here