Using share dialog in Android Facebook SDK. How to know is user actually shared or cancelled sharing activity?

前端 未结 6 2214
無奈伤痛
無奈伤痛 2021-01-11 09:41

I have added sharing functionality to Android app as described here https://developers.facebook.com/docs/android/share-dialog/#setup

But I have noticed that if user

6条回答
  •  無奈伤痛
    2021-01-11 10:05

    See https://developers.facebook.com/docs/android/share-dialog/#handling-responses

    You can tell if the user has cancelled by calling

    String gesture = FacebookDialog.getNativeDialogCompletionGesture(data);
    if (gesture != null) {
      if ("post".equals(gesture)) {
        // the user hit Post
      } else if ("cancel".equals(gesture)) {
        // the user hit cancel
      } else {
        // unknown value
      }
    } else {
      // either an error occurred, or your app has never been authorized
    }
    

    where data is the result bundle. However, it will only return a non-null value IF the user has logged in via your app (i.e. you have at least basic_info permissions). If the user has never logged in or authorized your app, then the only thing you'll see is the DID_COMPLETE, and it will always be true unless an error occurred. This is by design.

提交回复
热议问题