मैं अपने ऐप में पार्स एसडीके का उपयोग कर रहा हूं (https://github.com/ParsePlatform/Parse-SDK-Android)।पार्स एसडीके एंड्रॉइड - फेसबुक ग्राफ एपीआई v2.0
मेरा ऐप भी आदेश Facebook के साथ एक लॉगिन अनुभव प्रदान करने के लिए फेसबुक Utils का उपयोग करता है (https://github.com/ParsePlatform/ParseFacebookUtils-Android)
हाल ही में मैं फेसबुक डेवलपर्स से निम्न संदेश मेरे एप्लिकेशन में से एक के बारे में प्राप्त किया है: "xxx हाल कर रहा है एपीआई ग्राफ एपीआई v2.0 को कॉल करता है, जो सोमवार, 8 अगस्त, 2016 को 2 साल की बहिष्करण विंडो के अंत तक पहुंच जाएगा। कृपया संभावित टूटे हुए अनुभवों से बचने के लिए सभी कॉल v2.1 या उच्चतर में माइग्रेट करें। "
मैं उस समस्या को कैसे ठीक कर सकता हूं?
यह dependecies अनुभाग में मेरी build.gradle फ़ाइल है:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.parse:parse-android:1.13.1'
compile 'com.parse:parsefacebookutils-v4-android:[email protected]'
compile 'com.parse.bolts:bolts-tasks:1.4.0'
compile 'com.parse.bolts:bolts-applinks:1.4.0'
compile 'com.jeremyfeinstein.slidingmenu:library:[email protected]'
compile 'com.soundcloud.android:android-crop:[email protected]'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile files('libs/universal-image-loader-1.9.3.jar')
}
और इस कोड में केवल बिंदु है जहां मैं फेसबुक एसडीके का उपयोग करें:
ParseFacebookUtils.logInWithReadPermissionsInBackground(Login.this, permissions, new LogInCallback() {
@Override
public void done(final ParseUser user, ParseException err) {
fbdialog = new ProgressDialog(Login.this);
fbdialog.setTitle("Contacting Facebook");
fbdialog.setMessage("Please wait a moment. We are contacting Facebook to perform the registration");
fbdialog.show();
if (user == null) {
Log.d("MyApp", "Uh oh. The user cancelled the Facebook login.");
fbdialog.cancel();
} else if (user.isNew() || !user.isNew()) {
Log.d("MyApp", "User signed up and logged in through Facebook!" + AccessToken.getCurrentAccessToken());
GraphRequest request = GraphRequest.newMeRequest(
AccessToken.getCurrentAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
if(response!=null) {
try {
String nome = object.getString("name");
String email = object.getString("email");
String gender = object.getString("gender");
final String facebookid = object.getString("id");
ParseUser utente = ParseUser.getCurrentUser();
utente.put("namelastname", nome);
utente.put("email", email);
utente.put("gender", gender);
utente.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("idutente", user);
installation.saveInBackground();
//downloading the user profile image from facebook
AsyncTaskLoad as = new AsyncTaskLoad();
as.execute("https://graph.facebook.com/" + facebookid + "/picture?type=large");
fbdialog.cancel();
} else {
fbdialog.cancel();
e.printStackTrace();
}
}
});
} catch (JSONException e) {
e.printStackTrace();
}
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,link,email,age_range,gender,birthday");
request.setParameters(parameters);
request.executeAsync();
} else {
Log.d("MyApp", "User logged in through Facebook!");
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("idutente", user);
installation.saveInBackground();
fbdialog.cancel();
//here I start a new activity
}
}
});
}
});
इस प्रयोग किया जाता है AsyncTask है फेसबुक प्रोफाइल छवि डाउनलोड करने के लिए:
private class AsyncTaskLoad extends AsyncTask<String, Void, Void> {
@Override
protected void onPreExecute() {
pd = new ProgressDialog(Login.this);
pd.setTitle("Logging");
pd.show();
}
@Override
protected Void doInBackground(String... strings) {
try {
URL image_value = new URL(strings[0]);
SynchroHelper sync = new SynchroHelper(Login.this);
//simple http method to download an image and save it into a file in the external storage dir
sync.downloadImage(image_value.toString(), "myprof.jpg", Environment.getExternalStorageDirectory());
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void params) {
//starting a new activity...
pd.dismiss();
}
}
मैं ग्राफ़ एपीआई v2.0 में अपग्रेड कैसे कर सकता हूं? क्या मुझे पार्स-एसडीके से अपडेट का इंतजार करना चाहिए?
मुझे यह ईमेल भी मिला, मुझे नहीं पता कि इसे कैसे ठीक किया जाए। – Josh