Thursday, 15 September 2011

java - request id is null in Handle the Incoming Notification in facebook android sdk -



java - request id is null in Handle the Incoming Notification in facebook android sdk -

i'm trying handle incoming notification in facebook.

ref : http://developers.facebook.com/docs/howtos/androidsdk/3.0/app-link-requests/

code :

public class mainfragment extends fragment{ private static final string tag = "mainfragment"; private uilifecyclehelper uihelper; private string requestid; private textview username; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); log.d(tag, "mainfragment.oncreate()"); uihelper = new uilifecyclehelper(getactivity(), callback); uihelper.oncreate(savedinstancestate); } @override public view oncreateview(layoutinflater inflater, viewgroup container,bundle savedinstancestate) { log.d(tag, "mainfragment.oncreateview()"); view view = inflater.inflate(r.layout.login,container, false); loginbutton authbutton = (loginbutton) view.findviewbyid(r.id.loginbutton); authbutton.setreadpermissions(arrays.aslist("user_likes", "user_status")); authbutton.setfragment(this); username = (textview) view.findviewbyid(r.id.textusename); homecoming view; } @override public void onactivitycreated(bundle savedinstancestate) { super.onactivitycreated(savedinstancestate); log.d(tag, "mainfragment.onactivitycreated()"); // check incoming notification. save info // parse incoming notifications , save uri intenturi = getactivity().getintent().getdata(); if (intenturi != null) { string requestidparam = intenturi.getqueryparameter("request_ids"); if (requestidparam != null) { string array[] = requestidparam.split(","); requestid = array[0]; } } } private void onsessionstatechange(session session, sessionstate state, exception exception) { // check if user authenticated , // incoming notification needs handling log.d(tag,"mainfragment.onsessionstatechange()"); log.d(tag, "request id : "+requestid); if (state.isopened() && requestid != null) { log.d("request id", requestid); getrequestdata(requestid); toast.maketext(getactivity().getapplicationcontext(), "incoming request", toast.length_short).show(); requestid = null; } if (state.isopened()) { settings.addloggingbehavior(loggingbehavior.requests); request.executemerequestasync(session.getactivesession(), new graphusercallback() { @override public void oncompleted(graphuser user, response response) { if (user != null) { username.settext(user.getname()); } } }); } } private session.statuscallback callback = new session.statuscallback() { @override public void call(session session, sessionstate state, exception exception) { onsessionstatechange(session, state, exception); } }; private void getrequestdata(string requestid) { request request = new request(session.getactivesession(), requestid, null, httpmethod.get, new request.callback() { @override public void oncompleted(response response) { // process returned response graphobject graphobject = response.getgraphobject(); facebookrequesterror error = response.geterror(); log.d(tag, response.tostring()); // default message string message = "incoming request"; if( graphobject != null ) { // check if there info if ( graphobject.getproperty("data") != null ) { seek { // data, parse info key/value info jsonobject dataobject = new jsonobject(graphobject.getproperty("data").tostring()); // value key - badge_of_awesomeness string badge = dataobject.getstring("badge_of_awesomeness"); // value key - social_karma string karma = dataobject.getstring("social_karma"); // sender's name jsonobject fromobject =(jsonobject) graphobject.getproperty("from"); string sender = fromobject.getstring("name"); string title = sender+" sent gift"; // create text alert based on sender // , info message = title + "\n\n" + "badge: " + badge + " karma: " + karma; } grab (exception e) { e.printstacktrace(); } } toast.maketext(getactivity().getapplicationcontext(),message,toast.length_long).show(); } } }); log.d(tag, "request : "+request.tostring()); // execute request asynchronously. request.executebatchasync(request); } }

logcat

03-02 17:40:20.443: d/mainfragment(947): mainfragment.oncreate() 03-02 17:40:20.463: d/mainfragment(947): mainfragment.oncreateview() 03-02 17:40:20.753: d/mainfragment(947): mainfragment.onactivitycreated() 03-02 17:40:28.623: d/mainfragment(947): mainfragment.onsessionstatechange() 03-02 17:40:28.623: d/mainfragment(947): request id : null 03-02 17:40:30.673: d/mainfragment(947): mainfragment.onsessionstatechange() 03-02 17:40:30.673: d/mainfragment(947): request id : null 03-02 17:40:30.823: d/mainfragment(947): mainfragment.onsessionstatechange() 03-02 17:40:30.833: d/mainfragment(947): request id : null

now problem when click on notification using facebook android app app start can not request id notification.

app dashboard configuration

this problem have spent whole day on it. boban

this facebook bug. add together mobile web in app dashboard , request_ids

android app : handling app request posted on facebook

java android facebook facebook-android-sdk facebook-app-requests

No comments:

Post a Comment