When I invite friends from facebook it displays Toast invitation was send but not display in friends notification.
I use Simple Facebook SDK for Android in my app. My invite is sent, but it isn`t displayed in friends wall.
I asked the same question here: https://github.com/sromku/android-simple-facebook/issues/13
Can you tell me why I need Canvas?
Can you explain what is Canvas and why we need it to make invites work?
I read facebook Canvas explanation.
It is written that: "A Canvas Page is quite literally a blank canvas within Facebook on which to run your app. You populate the Canvas Page by providing a Canvas URL that contains the HTML, JavaScript and CSS that make up your app. When a user requests the Canvas Page, we load the Canvas URL within an iframe on that page. This results in your app being displayed within the standard Facebook chrome."
I don`t want my app to run from page, or it just will have a link to playstore?
What permissions I should ask?
Today I ask for: "user_friends","publish_actions".
Can you give me an example of invite friends that work with people that don`t have the app installed?
public void invite(String message, final OnInviteListener onInviteListener, String data) {
InviteAction inviteAction = new InviteAction(mSessionManager);
inviteAction.setMessage(message);
inviteAction.setData(data);
inviteAction.setOnInviteListener(onInviteListener);
inviteAction.execute();
}
#Override
protected void executeImpl() {
if (sessionManager.isLogin(true)) {
Bundle params = new Bundle();
if (mMessage != null) {
params.putString(PARAM_MESSAGE, mMessage);
}
if (mData != null) {
params.putString(PARAM_DATA, mData);
}
if (mTo != null) {
params.putString(PARAM_TO, mTo);
}
else if (mSuggestions != null) {
params.putString(PARAM_SUGGESTIONS, TextUtils.join(",", mSuggestions));
}
openInviteDialog(sessionManager.getActivity(), params, mOnInviteListener);
}
else {
String reason = Errors.getError(ErrorMsg.LOGIN);
Logger.logError(InviteAction.class, reason, null);
mOnInviteListener.onFail(reason);
}
}
The code is taken from Simple Facebook implementation. Am I missing something?
Thanks
Related
I have two apps one is android java app and other is unity app
Unity app recognize the object and shows some details. What i want to do is if user clicks the button which is shown when the object is identified, i want to send that information to the java android app so that the app can use that data to perform certain functions. How can i send the data and switch from unity to java android app after user clicks the button?
EDIT: For any one looking for the answer. I manage to do it by the code below
IN UNITY APP:
public void LaunchAppMessage()
{
string bundleId = "com.example.sidenavtest";
bool fail = false;
string message = "message";
AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject ca = up.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject packageManager = ca.Call<AndroidJavaObject>("getPackageManager");
AndroidJavaObject launchIntent = null;
try
{
launchIntent = packageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage", bundleId);
launchIntent.Call<AndroidJavaObject>("putExtra", "arguments", message);
}
catch (System.Exception e)
{
fail = true;
}
if (fail)
{
Application.OpenURL("https://google.com");
}
else
{
ca.Call("startActivity", launchIntent);
}
up.Dispose();
ca.Dispose();
packageManager.Dispose();
launchIntent.Dispose();
}
IN ANDROID APP
#Override
protected void onStart() {
super.onStart();
Bundle extras = getIntent().getExtras();
String userName;
if (extras != null) {
userName = extras.getString("arguments");
}
}
If i understand you correctly you want to have both applications on the same device.
Simplest way would be to save the data ino a file in the unity application and read from that file in the android application. But i think you can even attach data on application calls so that you dont even need to save it temporarily.
Opening the Android app from Unity is possible aswell. Here someone asked the same question and got some working answer.
Edit: From what i can gather you can transfer your data via intents, it seem's like most people work with JAR-Plugin from where you can make a intent call.
I am using Branch-io to share content like Text, image(from URL), and Link.
I am all done and working perfect with Facebook, Whatsapp. I mean I am able to share Text and Link on Gmail also but unable to attach image.
This problem occurred only with Gmail.
Here is my code:
BranchUniversalObject branchUniversalObject = new BranchUniversalObject()
.setCanonicalIdentifier("item/12345")
.setTitle(title)
.setContentDescription(message)
.setContentImageUrl(image)
//.setContentImageUrl(Uri.parse("file://"+downloadedImagePath).toString())
.setContentIndexingMode(BranchUniversalObject.CONTENT_INDEX_MODE.PUBLIC);
LinkProperties linkProperties = new LinkProperties()
.addControlParameter("$always_deeplink", "true")
.setFeature("sharing")
.setStage("1");
String body = "Text Message";
ShareSheetStyle shareSheetStyle = new ShareSheetStyle(mContext, mContext.getResources().getString(R.string.app_name), body)
.setAsFullWidthStyle(true)
.setSharingTitle("Share With");
branchUniversalObject.showShareSheet((Activity) mContext,
linkProperties,
shareSheetStyle,
new Branch.BranchLinkShareListener() {
#Override
public void onShareLinkDialogLaunched() {
LogUtils.v("Share Link", "Launched");
}
#Override
public void onShareLinkDialogDismissed() {
LogUtils.v("Share Link", "Dismissed");
}
#Override
public void onLinkShareResponse(String sharedLink, String sharedChannel, BranchError error) {
LogUtils.v("Share Link", sharedLink);
}
#Override
public void onChannelSelected(String channelName) {
LogUtils.v("Share Link", channelName);
}
});
}
}, false);
Let you know again, this code working perfect with Facebook, whatsapp but not with Gmail(only issue not attaching image).
If anyone knows then please let me know what I'am doing wrong and what is the perfect way to do this.
Thanks in advance.
I just tested this on our test application, and everything works correctly when sharing with Gmail. Here's my test link: https://appsolutely.test-app.link/Mw2qFHRMxJ
Whenever you share a link via showShareSheet(), all the Branch Universal Object (BUO) information is attached to the link. If you keep sharing links for the same data, but across different channels, the only difference between the links for each channel will be "~channel": "Gmail".
Looking at your code, I do not see any issues you could encounter with attaching the image URL, as you do call .setContentImageUrl(image) for the BUO object, so the issue may be in the way you are testing. After sharing your link via Gmail, I would suggest pasting it into the URL bar of your browser and attaching the following query parameter: ?debug=true.
E.g.: https://appsolutely.test-app.link/Mw2qFHRMxJ?debug=true
You could then view all of the data the link contains on the page that opens. If you see that the data contains the "$og_image_url" with the correct URL address, it means that the image was actually attached, as shown in the example below for my test link https://appsolutely.test-app.link/Mw2qFHRMxJ
Recently I tested 'deferred deeplink' function by using facebook SDK.
But there is one problem.
# I did it.
First, I have completed all of setting for apps by using the "App Ads Helper" function from developers.facebook.com.
https://developers.facebook.com/tools/app-ads-helper
Second, so I obtained the good result by using "DeepLink Test" provided by"App Ads Helper".
And I could see what i want (AppLinkData)
06-04 12:58:25.598 11903-11925/? I/DEBUG_FACEBOOK_SDK﹕ Bundle[{com.facebook.platform.APPLINK_NATIVE_CLASS=, target_url=myapp://myapp.co.kr?test=1111, com.facebook.platform.APPLINK_NATIVE_URL=myapp://myapp.co.kr?test=1111}]
Third, here is the code what I used.
protected void onCreate(){
....
FacebookSdk.sdkInitialize(getApplicationContext());
AppLinkData.fetchDeferredAppLinkData(getApplicationContext(),
BSTracker.getInstance().getFacebookIdMeta() ,
new AppLinkData.CompletionHandler() {
#Override
public void onDeferredAppLinkDataFetched(AppLinkData appLinkData) {
if (appLinkData != null) {
Bundle bundle = appLinkData.getArgumentBundle();
Log.i("DEBUG_FACEBOOK_SDK", bundle.toString());
} else {
Log.i("DEBUG_FACEBOOK_SDK", "AppLinkData is Null");
}
}
});
}
Finally. This is My App Setting
Ad Setting
It is My Ad setting.
i did input the DeepLink in "Get install of your App" Ad Product.
# Problem
When I created commercial ad at Facebook and released for the audience but I can't get Deferred DeepLink.
Please let me know, anything is wrong with it.
I'm trying to implement Facebook sharing in my game using Unity 3D + Facebook Unity SDK. But when I tried testing to post to my wall, this error shows up: "We are Sorry, this post is no longer available. It may have been removed." Can anybody help me? Thanks in advance.
BTW, here's my code:
using UnityEngine;
using System.Collections;
public class FacebookController : MonoBehaviour {
public bool isUsingFacebook = true; //Are we using Facebook SDK? This variable is only
//Feed parameters.
private string link = "market://details?id=com.LaserCookie.Queue"; //The link that will show the user the game's google play store address
private string linkName = "Queue"; //The link name
private string linkCaption = "Wow this game is great! 10/10 must play!"; // The caption of the link
private string linkDescription = "I achieved the score of " + PlayerController.instance.score.ToString() + "! Try to beat me if you can!"; //The description of the link
private string picture = "http://www.drycreekequestriancenter.com/testImage.jpeg"; //This is the image / game icon for the link. For now, it's shamelessly got from a random source. Thank you, random citizen...
void Awake()
{
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
//Init FB
private void Init()
{
if (!FB.IsInitialized)
{
FB.Init(OnInitComplete, OnHideUnity);
}
}
//Callback that will be called when the initialization is completed
private void OnInitComplete()
{
Debug.Log("FB.Init completed: Is user logged in? " + FB.IsLoggedIn);
//Check if we are logged in.
//If not, we will log in.
//If we are, post status.
if (!FB.IsLoggedIn)
{
LoginWithPublish();
}
else
{
PostImpl();
}
}
//Callback that will be called when the game is shown / not
private void OnHideUnity(bool isGameShown)
{
Debug.Log("Is game showing? " + isGameShown);
}
//Post to Facebook. This is the only exposed method because we only use this to post to Facebook.
//The initialization and login will be called when needed.
//It will first detect whether or not we have been initialized. And will init if we haven't.
//Then it will check whether or not we have been logged in with publish. And will log in if not.
public void PostToFacebook()
{
//Are we using facebook SDK?
if (isUsingFacebook)
{
if (!FB.IsInitialized) //Check for initialization
{
Init();
}
else if (!FB.IsLoggedIn) //Check for login
{
LoginWithPublish();
}
else //Post if we are already initia;ized and logged in
{
PostImpl();
}
}
}
//The true implementation of the posting
private void PostImpl()
{
FB.Feed("",link, linkName,linkCaption,linkDescription,picture);
}
//Login to Facebook with publish
private void LoginWithPublish()
{
// It is generally good behavior to split asking for read and publish
// permissions rather than ask for them all at once.
//
// In your own game, consider postponing this call until the moment
// you actually need it.
FB.Login("publish_actions", LoginCallback);
}
//Login callback
void LoginCallback(FBResult result)
{
if (result.Error != null)
{
Debug.Log( "Error Response:\n" + result.Error );
//TODO: Retry login if we have error? Or do we display a pop up?
}
else if (!FB.IsLoggedIn)
{
Debug.Log( "Login cancelled by Player" );
//TODO: Do we display a pop up?
}
else
{
Debug.Log( "Login was successful!" );
PostImpl();
}
}
}
You need to add Key Hash for FB application.
Go to My Apps, select you application, open Setting tab, add platform for android, and add you key hash.
check this link out
Setting a Release Key Hash
I've fixed the issue. It turns out it's because I used my still in development google store address as the link. I thought it would be automatically recognized regardless of my app is live or not. Thank you anyway. :)
I used the following codes in my android app that can "like" to a specific link via facebook. But when I task, it asked me to login even though I already logged into facebook android app and web browser also. I don't know why. Can anybody answer me?
private void appendUrl(String url, String appId,
FacebookLikeOptions options, StringBuilder sb)
{
sb.append("<iframe ");
sb.append("style='");
sb.append("display:block;clear:both;border:none;overflow:hidden;");
sb.append("width:100%;");
sb.append("'");
sb.append("src='//www.facebook.com/plugins/like.php");
//noinspection deprecation
sb.append("?href=").append(URLEncoder.encode(url));
sb.append("&layout=").append(options.getLayoutString());
sb.append("&action=").append(options.getActionString());
sb.append("&show_faces=").append(options.showFaces);
sb.append("&share=").append(options.share);
if (appId != null && appId.trim().length() > 0)
{
sb.append("&appId=").append(appId);
}
sb.append("'");
sb.append("scrolling='no'");
sb.append("frameborder='0'");
sb.append("allowTransparency='true'");
sb.append("></iframe>");
}