IOS,Android-Facebook分享

Fackbook

新建应用:

https://developers.facebook.com

对外开放

这里写图片描述

审核通过publish_actions

IOS提交模拟器版本,Unity中选择Mono2x,Simulator SDK,禁用部分第三方SDK
sim_build

IOS

导入UMSDK,导入facebook-sdk

设置url Schemes

<!-- Facebook -->
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLName</key>
            <string>fb</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fbxxxxxxxxxxxxxxx</string>
            </array>
        </dict>

添加url Schemes白名单

        <string>fbapi</string>
        <string>fb-messenger-api</string>
        <string>fbauth2</string>
        <string>fbauth</string>
        <string>fbshareextension</string>

编辑其他plist

        <key>FacebookAppID</key>
        <string>xxxxxxxxxxxxxxx</string>
        <key>FacebookDisplayName</key>
        <string>XXXXXXXXXXX</string>

初始化

//设置友盟appkey
    [[UMSocialManager defaultManager] setUmSocialAppkey:@"xxxxxxxxxxxxxxx"];
    [[UMSocialManager defaultManager] openLog:YES];
//设置Facebook的appKey和UrlString
    [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_Facebook appKey:@"xxxxxxxxxxxxxxx"  appSecret:nil redirectURL:@"http://fir.im/minelost"];

开启Keychain Sharing

这里写图片描述

Android

Facebook后台设置

包名(com.xxxx.xxxx)
类名[应用主要的Activity](com.xxxx.xxxx.xxActivity)
密钥散列:

keytool -exportcent -alias androiddebugkey -keystore xxxx.keystore | openssl sha1 -binary | openssl base64

配置AndroidManifest

<activity
        android:name="com.umeng.facebook.FacebookActivity"
        android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Translucent.NoTitleBar" />
    <provider
        android:name="com.umeng.facebook.FacebookContentProvider"
        android:authorities="com.facebook.app.FacebookContentProviderxxxxxxxxxxxxxxx"
        android:exported="true" />

    <meta-data
        android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/facebook_app_id" />

猜你喜欢

转载自blog.csdn.net/wlz1992614/article/details/62044026