Hi All,
In this blog post we are going to discuss how to integrate Facebook with PhoneGap.
To integrate Facebook with Android you need to register your app with Facebook first.
To register your App with Facebook follow below steps:
1. Navigate to https://developers.facebook.com/
2. Log in with your Facebook Account.
3. Click on my Apps
![alt text](https://findnerd.s3.amazonaws.com/data/142890829523.PNG)
4. Add a new Application
5. Select a platform to get started. In this case we will select Android
![alt text](https://findnerd.s3.amazonaws.com/data/142890881430.PNG)
6. Click on Skip and create App Id.
![alt text](https://findnerd.s3.amazonaws.com/data/142890881510.PNG)
7. After fill Display Name,Name Spaces and category you can get your app Id and App Secret. Copy App Id for future Use.
![alt text](https://findnerd.s3.amazonaws.com/data/142890881727.PNG)
![alt text](https://findnerd.s3.amazonaws.com/data/142890881815.PNG)
8. After getting App Id click on Settings on left side Menu.
![alt text](https://findnerd.s3.amazonaws.com/data/142891063899.PNG)
9.Click on Add Platforms.
![alt text](https://findnerd.s3.amazonaws.com/data/142891063852.PNG)
Fill form with:
I. Google play package Name:Unique app identifier used to open your App For
ex: com.app.xyz
II. Class Name: The main activity you want Facebook to launch
For Ex: xyz
![alt text](https://findnerd.s3.amazonaws.com/data/142891063885.PNG)
III. Key Hashes: To generate Key Hashes write following code on your main java class of your app:
try {
PackageInfo info = getPackageManager().getPackageInfo("com.app.myApp", PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures){
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash:", Base64.encodeToString(md.digest(),Base64.DEFAULT));
}
}
catch (NameNotFoundException e) {
}
catch (NoSuchAlgorithmException e) {
}
}
Import Following packages:
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.Signature;
import android.util.Base64;
import android.util.Log;
Run your application and copy Key Hashes from console and fill it into form.
10. Click on App Details option on the sidebar and add the relevant information about the app.
11. Turn on the App Center Platform settings for your mobile/web site
to list your app in app center.
12. Add icons, images, and videos as specified in the settings page. The images and icons need to be of the mentioned size and resolution.
After the app registration is done you need to upload the APK for your app and submit it for review to Facebook team. It takes 5 business days for the team to approve your app.you can start using the App ID generated to implement Facebook functionality in your app before approval as well.
0 Comment(s)