Android 无法从Facebook SDK、Graph API获取所有通知
我正在制作一个应用程序,我需要从Facebook获得所有新的通知。我成功登录并获得应用程序的管理通知权限。这段代码成功地从facebook加载了JSON字符串Android 无法从Facebook SDK、Graph API获取所有通知,android,facebook-graph-api,Android,Facebook Graph Api,我正在制作一个应用程序,我需要从Facebook获得所有新的通知。我成功登录并获得应用程序的管理通知权限。这段代码成功地从facebook加载了JSON字符串 Session session = Session.openActiveSessionFromCache(ctx); if (session != null && session.isOpened()) { Request notificationsRequest = Request.newGrap
Session session = Session.openActiveSessionFromCache(ctx);
if (session != null && session.isOpened()) {
Request notificationsRequest = Request.newGraphPathRequest(
session, "/me/notifications",
new Request.Callback() {
@Override
public void onCompleted(Response response) {
GraphObject object = response
.getGraphObject();
if (object != null) {
notificationsNewString = object
.getInnerJSONObject()
.toString();
try {
notificationsOldString = saver.getJsonFromInternalCache();
} catch (IOException e) {
notificationsOldString = null;
}
try {
compareOldAndNewData();
} catch (ParseException e) {
e.printStackTrace();
}
createNotif();
} else {
notificationsNewString = "Notifications returns null";
}
}
});
Request.executeBatchAndWait(notificationsRequest);
} else {
Log.i("TAGTAG", "Session not open!");
}
但有些人在应用程序上有困难,因为Facebook不会发送所有新的通知。特别是当有人评论他们评论的状态时通知。(在Facebook上,它被标记为一个新通知,但json是空的)
是关于一些权限还是它是bug
谢谢。我找到了另一种方法。我会把它贴出来,以防有人觉得有用
private void onSessionStateChange(Session session, SessionState state, Exception exception) {
if (state.isOpened()) {
InboxMessage.setVisibility(View.VISIBLE);
new Request(session,"/me/notifications", null,HttpMethod.GET,new Request.Callback() {
public void onCompleted(Response response) {
GraphObject object = response.getGraphObject();
if (object != null) {
InboxMessage.setText(object.getProperty("data").toString());
} else {
InboxMessage.setText("Notifications returns null");
}
}
}
).executeAsync();
} else {
InboxMessage.setVisibility(View.INVISIBLE);
Log.i(TAG, "Logged out...");
}
}
您好,我有同样的问题,我已经创建了一个错误报告: