Facebook sdk接入

This commit is contained in:
Caiyanpeng committed 2021-12-23 15:36:11 +08:00
1 parent 4260cf05d3
commit 6423007638
123 files changed
+6764 -39

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3f5f2fb4268a83643a462f3717ee7f97
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,154 @@
fileFormatVersion: 2
guid: fb286cd0f33ce4f5e81baf10dab8d865
timeCreated: 1561663365
licenseType: Pro
PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
'': Any
second:
enabled: 0
settings:
Exclude Android: 0
Exclude Editor: 1
Exclude Linux: 1
Exclude Linux64: 1
Exclude LinuxUniversal: 1
Exclude OSXIntel: 1
Exclude OSXIntel64: 1
Exclude OSXUniversal: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 1
Exclude tvOS: 1
data:
first:
'': Editor
second:
enabled: 0
settings:
CPU: AnyCPU
OS: AnyOS
data:
first:
Android: Android
second:
enabled: 1
settings:
CPU: ARMv7
data:
first:
Any:
second:
enabled: 0
settings: {}
data:
first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
data:
first:
Facebook: Win
second:
enabled: 0
settings:
CPU: None
data:
first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: LinuxUniversal
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXIntel
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXIntel64
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
data:
first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
iPhone: iOS
second:
enabled: 0
settings:
CompileFlags:
FrameworkDependencies:
data:
first:
tvOS: tvOS
second:
enabled: 0
settings:
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 304660bc365f9034db9aa6872a54f6b8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: abcfdae5d23df40e9a7ec554ddc17a22
timeCreated: 1623191241
PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
Android: Android
second:
enabled: 1
settings: {}
data:
first:
Any:
second:
enabled: 0
settings: {}
data:
first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c306adc6985aea64e8e8a093aba2e61c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,276 @@
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
* copy, modify, and distribute this software in source code or binary form for use
* in connection with the web services and APIs provided by Facebook.
*
* As with any software that integrates with the Facebook platform, your use of
* this software is subject to the Facebook Developer Principles and Policies
* [http://developers.facebook.com/policy/]. This copyright notice shall be
* included in all copies or substantial portions of the software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var FBUnityLib = {
$FBUnity: {
init: function(connectFacebookUrl, locale, debug, initParams, status) {
// make element for js sdk
if (!document.getElementById('fb-root')) {
var fbroot = document.createElement('div');
fbroot.id = 'fb-root';
var body = document.getElementsByTagName('body')[0];
body.insertBefore(fbroot, body.children[0]);
}
// load js sdk
var js, id = 'facebook-jssdk', ref = document.getElementsByTagName('script')[0];
if (document.getElementById(id)) {return;}
js = document.createElement('script'); js.id = id; js.async = true;
js.src = connectFacebookUrl + '/' + locale + '/sdk' + (debug ? '/debug' : '') + '.js';
ref.parentNode.insertBefore(js, ref);
// once jssdk is loaded, init
window.fbAsyncInit = function() {
initParams = JSON.parse(initParams);
initParams.hideFlashCallback = FBUnity.onHideUnity;
FB.init(initParams);
// send url to unity - needed for deep linking
FBUnity.sendMessage('OnUrlResponse', location.href);
if (status) {
FBUnity.onInitWithStatus();
} else {
FBUnity.onInit();
}
};
},
initScreenPosition: function() {
if (!screenPosition) {
var body = document.getElementsByTagName('body')[0];
var screenPosition = {omo : body.onmouseover || function(){}, iframeX: 0, iframeY: 0};
body.onmouseover = function(e) {
// Distance from top of screen to top of client area
screenPosition.iframeX = e.screenX - e.clientX;
screenPosition.iframeY = e.screenY - e.clientY;
screenPosition.omo(e);
}
}
},
sendMessage: function(method, param) {
SendMessage('FacebookJsBridge', method, param);
},
login: function(scope, callback_id) {
FB.login(FBUnity.loginCallback.bind(null, callback_id), scope ? {scope: scope, auth_type: 'rerequest', return_scopes: true} : {return_scopes: true});
},
loginCallback: function(callback_id, response) {
response = {'callback_id': callback_id, 'response': response};
FBUnity.sendMessage('OnLoginComplete', JSON.stringify(response));
},
onInitWithStatus: function() {
var timeoutHandler = setTimeout(function() { requestFailed(); }, 3000);
function requestFailed() {
FBUnity.onInit();
}
// try to get the login status right after init'ing
FB.getLoginStatus(function(response) {
clearTimeout(timeoutHandler);
FBUnity.onInit(response);
});
},
onInit: function(response) {
var jsonResponse = '';
if (response && response.authResponse) {
jsonResponse = JSON.stringify(response);
}
FBUnity.sendMessage('OnInitComplete', jsonResponse);
FB.Event.subscribe('auth.authResponseChange', function(r){ FBUnity.onAuthResponseChange(r) });
FBUnity.logLoadingTime(response);
},
logLoadingTime: function(response) {
FB.Canvas.setDoneLoading(
function(result) {
// send implicitly event to log the time from the canvas pages load to facebook init being called.
FBUnity.logAppEvent('fb_canvas_time_till_init_complete', result.time_delta_ms / 1000, null);
}
);
},
onAuthResponseChange: function(response) {
FBUnity.sendMessage('OnFacebookAuthResponseChange', response ? JSON.stringify(response) : '');
},
apiCallback: function(query, response) {
response = {'query': query, 'response': response};
FBUnity.sendMessage('OnFacebookAPIResponse', JSON.stringify(response));
},
api: function(query) {
FB.api(query, FBUnity.apiCallback.bind(null, query));
},
activateApp: function() {
FB.AppEvents.activateApp();
},
uiCallback: function(uid, callbackMethodName, response) {
response = {'callback_id': uid, 'response': response};
FBUnity.sendMessage(callbackMethodName, JSON.stringify(response));
},
logout: function() {
FB.logout();
},
logAppEvent: function(eventName, valueToSum, parameters) {
FB.AppEvents.logEvent(
eventName,
valueToSum,
JSON.parse(parameters)
);
},
logPurchase: function(purchaseAmount, currency, parameters) {
FB.AppEvents.logPurchase(
purchaseAmount,
currency,
JSON.parse(parameters)
);
},
ui: function(x, uid, callbackMethodName) {
x = JSON.parse(x);
FB.ui(x, FBUnity.uiCallback.bind(null, uid, callbackMethodName));
},
hideUnity: function(direction) {
direction = direction || 'hide';
//TODO support this for webgl
var unityDiv = jQuery(u.getUnity());
if (direction == 'hide') {
FBUnity.sendMessage('OnFacebookFocus', 'hide');
} else /*show*/ {
FBUnity.sendMessage('OnFacebookFocus', 'show');
if (FBUnity.showScreenshotBackground.savedBackground) {
/*
if(fbShowScreenshotBackground.savedBackground == 'sentinel') {
jQuery('body').css('background', null);
} else {
jQuery('body').css('background', fbShowScreenshotBackground.savedBackground);
}
*/
}
hideUnity.savedCSS = FBUnity.showScreenshotBackground.savedBackground = null;
}
},
showScreenshotBackground: function(pngbytes) /*and hide unity*/ {
// window.screenxX and window.screenY = browser position
// window.screen.height and window.screen.width = screen size
// findPos, above, locates the iframe within the browser
/*
if (!fbShowScreenshotBackground.savedBackground)
fbShowScreenshotBackground.savedBackground = jQuery('body').css('background') || 'sentinel';
jQuery('body').css('background-image', 'url(data:image/png;base64,'+pngbytes+')');
jQuery('body').css(
'background-position',
-(screenPosition.iframeX)+'px '+
-(screenPosition.iframeY)+'px'
);
jQuery('body').css('background-size', '100%');
jquery('body').css('background-repeat', 'no-repeat');
// TODO: Zoom detection
*/
},
onHideUnity: function(info) {
if (info.state == 'opened') {
FBUnity.sendMessage('OnFacebookFocus', 'hide');
} else {
FBUnity.sendMessage('OnFacebookFocus', 'show');
}
}
},
init: function(connectFacebookUrl, locale, debug, initParams, status) {
var connectFacebookUrlString = Pointer_stringify(connectFacebookUrl);
var localeString = Pointer_stringify(locale);
var initParamsString = Pointer_stringify(initParams);
FBUnity.init(connectFacebookUrlString, localeString, debug, initParamsString, status);
},
initScreenPosition: function() {
FBUnity.initScreenPosition();
},
login: function(scope, callback_id) {
var scopeString = Pointer_stringify(scope);
var scopeArray = JSON.parse(scopeString);
var callback_idString = Pointer_stringify(callback_id);
FBUnity.login(scopeArray, callback_idString);
},
activateApp: function() {
FBUnity.activateApp();
},
logout: function() {
FBUnity.logout();
},
logAppEvent: function(eventName, valueToSum, parameters) {
var eventNameString = Pointer_stringify(eventName);
var parametersString = Pointer_stringify(parameters);
FBUnity.logAppEvent(eventNameString, valueToSum, parametersString);
},
logAppEventWithoutValue: function(eventName, parameters) {
var eventNameString = Pointer_stringify(eventName);
var parametersString = Pointer_stringify(parameters);
FBUnity.logAppEvent(eventNameString, null, parametersString);
},
logPurchase: function(purchaseAmount, currency, parameters) {
var currencyString = Pointer_stringify(currency);
var parametersString = Pointer_stringify(parameters);
FBUnity.logPurchase(purchaseAmount, currencyString, parametersString);
},
ui: function(x, uid, callbackMethodName) {
var xString = Pointer_stringify(x);
var uidString = Pointer_stringify(uid);
var callbackMethodNameString = Pointer_stringify(callbackMethodName);
FBUnity.ui(xString, uidString, callbackMethodNameString);
}
};
autoAddDeps(LibraryManager.library, '$FBUnity');
mergeInto(LibraryManager.library, FBUnityLib);
@@ -0,0 +1,36 @@
fileFormatVersion: 2
guid: 082cd93ddb11e4437b52ea3d121816d8
timeCreated: 1561663365
licenseType: Pro
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Facebook: WebGL
second:
enabled: 1
settings: {}
- first:
WebGL: WebGL
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,160 @@
fileFormatVersion: 2
guid: c57105322a98c474faf1ce607f20c3f8
timeCreated: 1561663364
licenseType: Pro
PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
'': Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux: 1
Exclude Linux64: 1
Exclude LinuxUniversal: 1
Exclude OSXIntel: 1
Exclude OSXIntel64: 1
Exclude OSXUniversal: 1
Exclude WebGL: 0
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 1
Exclude tvOS: 1
data:
first:
'': Editor
second:
enabled: 0
settings:
CPU: AnyCPU
OS: AnyOS
data:
first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
data:
first:
Any:
second:
enabled: 0
settings: {}
data:
first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
data:
first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: x86
data:
first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: x86_64
data:
first:
Standalone: LinuxUniversal
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXIntel
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Standalone: OSXIntel64
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Win
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
WebGL: WebGL
second:
enabled: 1
settings: {}
data:
first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
iPhone: iOS
second:
enabled: 0
settings:
CompileFlags:
FrameworkDependencies:
data:
first:
tvOS: tvOS
second:
enabled: 0
settings:
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bd6f82586c983d14881ca1a5d869b5c7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<dependencies>
<androidPackages>
<androidPackage spec="com.parse.bolts:bolts-android:1.4.0" />
<androidPackage spec="com.facebook.android:facebook-core:[11.0, 12)" />
<androidPackage spec="com.facebook.android:facebook-applinks:[11.0, 12)" />
<androidPackage spec="com.facebook.android:facebook-login:[11.0, 12)" />
<androidPackage spec="com.facebook.android:facebook-share:[11.0, 12)" />
<androidPackage spec="com.facebook.android:facebook-gamingservices:[11.0, 12)" />
</androidPackages>
<iosPods>
<iosPod name="FBSDKCoreKit_Basics" version="~> 11.0" />
<iosPod name="FBSDKCoreKit" version="~> 11.0" />
<iosPod name="FBSDKLoginKit" version="~> 11.0" />
<iosPod name="FBSDKShareKit" version="~> 11.0" />
<iosPod name="FBSDKGamingServicesKit" version="~> 11.0" />
</iosPods>
</dependencies>
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1543e5f9bab73423c96b42cab90363ab
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 137a102f808364a0fb444bedefe2575d
timeCreated: 1561663361
licenseType: Pro
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 08462833fafe743b8bd59914b9f52696
timeCreated: 1561663359
licenseType: Pro
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 56e97142b4054564b818ddb4a996bcbf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 99f23b07cdda04baea08736723cf3aad
timeCreated: 1561663362
licenseType: Pro
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: cfd587f32401443d0b223aa6246fe5bc
timeCreated: 1561663364
licenseType: Pro
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 89644ab96437bb3429d31f916a4c37c7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: c49f2b3ca212b47fc9cd8ce655177c89
timeCreated: 1561663363
licenseType: Pro
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d215dd8cabdd0444795d89904078812a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,154 @@
fileFormatVersion: 2
guid: 516664901472b44fe83b720b195b5b60
timeCreated: 1561663362
licenseType: Pro
PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
'': Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux: 1
Exclude Linux64: 1
Exclude LinuxUniversal: 1
Exclude OSXIntel: 1
Exclude OSXIntel64: 1
Exclude OSXUniversal: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 0
Exclude tvOS: 1
data:
first:
'': Editor
second:
enabled: 0
settings:
CPU: AnyCPU
OS: AnyOS
data:
first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
data:
first:
Any:
second:
enabled: 0
settings: {}
data:
first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
data:
first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: x86
data:
first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: x86_64
data:
first:
Standalone: LinuxUniversal
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXIntel
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Standalone: OSXIntel64
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Win
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
iPhone: iOS
second:
enabled: 1
settings:
CompileFlags:
FrameworkDependencies:
data:
first:
tvOS: tvOS
second:
enabled: 0
settings:
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant: