Native sharing requires the Facebook for Android application - facebook

i have installed Facebook Android app,but my code
public void shareUsingNativeDialog() {
if (playerChoice == INVALID_CHOICE || computerChoice == INVALID_CHOICE) {
ShareContent content = getLinkContent();
// share the app
if (shareDialog.canShow(content, ShareDialog.Mode.NATIVE)) {
shareDialog.show(content, ShareDialog.Mode.NATIVE);
} else {
showError(R.string.native_share_error);
}
} else {
ShareContent content = getThrowActionContent();
if (shareDialog.canShow(content, ShareDialog.Mode.NATIVE)) {
shareDialog.show(content, ShareDialog.Mode.NATIVE);
} else {
showError(R.string.native_share_error);
}
}
}
it's tip Native sharing requires the Facebook for Android application.
so why??

No need, default mode of ShareDialog will be Mode.AUTOMATIC. It will check if the facebook app is installed.

Related

navigationtype of WKWebView in flutter webview

i have this code in Xamarin for translate to flutter.
whith the class WKNavigationAction i can know if the url to navigate comes from a user click or javascript
My interest is traslate this statement to flutter
navigationAction.NavigationType == WebKit.WKNavigationType.LinkActivated)
public override void DecidePolicy(WKWebView webView, WKNavigationAction navigationAction, Action<WKNavigationActionPolicy> decisionHandler)
{
string url = navigationAction.Request.ToString();
// send external links out of the web domain if the user clicked in link
if (!StartsWihtBaseUrl(url) && navigationAction.NavigationType == WebKit.WKNavigationType.LinkActivated)
{
decisionHandler(WKNavigationActionPolicy.Cancel);
ExternalUrlManager.Instance.ManageExternalUrl(url);
}
else
{
decisionHandler(WKNavigationActionPolicy.Allow);
}
}
}
...

How to see what device is used?

I need to customize web app whether it is used on laptop or phone, found ios or android detection, so would it work if I just did:
if (android or ios) {return phone version} else {computer version} ?
SOLUTION
solutions below gave me an error, but this package helped me:
https://pub.dev/packages/universal_io
checkOS() {
if (Platform.isAndroid || Platform.isIOS) {
return PhoneVersion;
} else {
return ComputerVersion,
);
}
}
or
log('os: ${Platform.operatingSystem}');
You can use Platform class:
import 'dart:io';
bool isDesktop = (Platform.isWindows || Platform.isMacOS || Platform.isLinux);
bool isMobile = (Platform.isIOS || Platform.isAndroid);
also you can use kIsWeb:
import 'package:flutter/foundation.dart';
if (kIsWeb) {
// HORIZONTAL LAYOUT
} else {
// VERTICAL LAYOUT
}
if (Platform.isAndroid) {
// Do Android case
} else {
// Do other case
}
For retrieving more information about user's device, use packages like device_info.

Is it possible to track app installs using the Facebook Unity SDK without logging the user into Facebook?

I am trying to setup a Facebook marketing campaign with the objective being to track app installs. Facebook recommends using their SDK to get accurate information about app installs, but I don't want to prompt the user to login to Facebook in my app. Is it possible to have the Facebook SDK track app installs without users logging in? According to Facebook their API automatically tracks app installs but it seems that in their initialization script called mainmenu.cs requires a Facebook login to occur.
What I did was basically create a persistent game object in my first scene and attached this code to it. I based this code off of Facebook's example https://developers.facebook.com/docs/app-events/unity but added some additional checks so FB.Init() would not be called twice. I also added a coroutine that would wait to activate an event until FB.Init() is done since FB.Init() is an asynchronous function.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Facebook.Unity;
public class FacebookTracker : MonoBehaviour {
private static FacebookTracker instance;
private bool initCalled;
private void Awake()
{
if (instance == null)
{
instance = this;
DontDestroyOnLoad(gameObject);
} else
{
Destroy(gameObject);
}
if (FB.IsInitialized == false && initCalled == false)
{
FB.Init();
initCalled = true;
}
}
private void OnApplicationPause(bool pause)
{
Debug.Log("OnApplicationPause = " + pause);
if (pause == false)
{
if (FB.IsInitialized == true)
{
FB.ActivateApp();
} else
{
if (initCalled == false)
{
FB.Init();
initCalled = true;
}
StartCoroutine(ActivateEvent());
}
}
}
private IEnumerator ActivateEvent()
{
yield return new WaitUntil(() => FB.IsInitialized == true);
Debug.Log("Facebook Activate Event Logged");
FB.ActivateApp();
}
}

Sharing on Facebook from Uniy3D

Hi ther I am working on a project for Android and I have a button. When the user press the button I want to give him/her the oportunity to share on facebook. This is the code that I am using:
public void ShareOnFacebook()
{
List<string> permission = new List<String>();
permission.Add("publish_actions");
if(!FB.IsLoggedIn)
FB.LogInWithPublishPermissions(permission, null);
FB.FeedShare(
string.Empty,
new Uri("http://linktoga.me"),
"Hello this is the title",
"This is the caption",
"Check out this game",
new Uri("https://i.ytimg.com/vi/NtgtMQwr3Ko/maxresdefault.jpg"),
string.Empty,
callback:ShareCallBack
);
}
void ShareCallBack(IResult result)
{
if (result.Cancelled)
{
Debug.Log("Share Cancelled");
}
else if (!string.IsNullOrEmpty(result.Error))
{
Debug.Log("Error on share!");
}
else if (!string.IsNullOrEmpty(result.RawResult))
{
Debug.Log("Success on share");
}
}
Now the problem is that when I test this on my Android device a Facebook window pops up with a message : "There was a problem. Please try again later".
I am using Facebook SDK 7.4.0

Page-tab: show overlay in iframe depending on Like

I wanna add an overlay (already built the HTML 'n jQuery) to a custom iframe tab, that only shows if people haven't liked my client's page yet. Is this possible with the JS SDK? How would I go about this?
While this is better done server-side, you code use something like:
FB.api('/me/likes/PAGE_ID',function(response) {
if( response.data ) {
if( !isEmpty(response.data) )
alert('You are a fan!');
else
alert('Not a fan!');
} else {
alert('ERROR!');
}
});
// function to check for an empty object
function isEmpty(obj) {
for(var prop in obj) {
if(obj.hasOwnProperty(prop))
return false;
}
return true;
}
The code is taken from my tutorial.