简体   繁体   中英

libgdx and robovm, opening the facebook share dialog

Does anyone have a working example of using robovm(and facebook robopods i assume) to open the facebook share dialog on IOS? I have tried every solution I can find with no success :( All solutions use something along the line of:

 dialog = new FBSDKShareDialog();
 dialog.setFromViewController(getWindow().getRootViewController());
 dialog.setShareContent(content);
 dialog.show();

But it always crashes at the dialog.show part.

The show method can only be called in the main queue (I believe it is the same as the ui thread). You can force it there using the following example:

final FBSDKShareDialog dialog = new FBSDKShareDialog();
dialog.setShareContent(content);
dialog.setFromViewController(application.getRootApplication().getUIViewController());


NSOperationQueue.getMainQueue().addOperation(new Runnable() {
    @Override
    public void run() {
        if (dialog.canShow())
            dialog.show();
        //else
        //    fallback();
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM