Comparing Facebook and Google+ Login Integration for Android Apps
Recently, I had the opportunity to implement Facebook and Google+ login functionalities into an Android application. I decided to write a brief comparison of the two integration processes using Facebook SDK v4.3 and Google Play Services v4.3.23.
Google+
- Server-Side Setup: Requires creating a new app on the Google Developers Console.
- Android Manifest: You need to add the generated API key into the Android manifest file.
- Implementation: Involves a few methods. Your activity needs to implement
ConnectionCallbacks
andOnConnectionFailedListener
.
- Server-Side Setup: Also requires creating a new app on the Facebook Developers site.
- Android Manifest: You need to add the generated API key to the Android manifest and declare one activity.
- SDK Compatibility: The SDK is not compatible with Eclipse directly; however, there are workarounds available on Stack Overflow.
- XML Customization: Customizing the Facebook button in XML requires overwriting styles in the Facebook SDK, which is not the recommended approach.
- Implementation: Involves just a few lines of code for initialization, setting up the button listener, and handling
onActivityResult
. - Error Handling: If an invalid fingerprint is used for debug/release keys, the error message reveals the value of your key, which can be useful for debugging.
Conclusion
Despite some drawbacks with Facebook, such as SDK compatibility and XML customization issues, their documentation is exceptionally helpful. Both Facebook and Google+ offer step-by-step tutorials for initialization, but I found myself stuck for about half a day with Google+ implementation. The issue was that I missed a crucial line not included in the main documentation. Ultimately, I resolved it through a Stack Overflow discussion.
Overall, while both platforms have their quirks, they each provide robust solutions for integrating social logins into Android applications.
/* Client used to interact with Google APIs. */
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
//use
.addApi(Plus.API, Plus.PlusOptions.builder().build())
//instead of
//addApi(Plus.API)
.addScope(Scopes.PLUS_LOGIN)
.addScope(Scopes.PLUS_ME)
.build();
Comments
Post a Comment