Meta and appflyer deeper intregration

This commit is contained in:
Savya Bikram Shah
2026-06-07 14:12:09 +05:45
parent 70b8dd2b95
commit a07f7618ab
200 changed files with 9081 additions and 2300 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b0fa1e02c18a7477192d40dbde1fbb94
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/FacebookSDK/Plugins/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6c1e341b7555e4e68bca6fe9ec10b0d0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,31 @@
fileFormatVersion: 2
guid: fb286cd0f33ce4f5e81baf10dab8d865
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ac0fbda9ff1a44a2084461c42e8dd911
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 990773b858e104eb1b6ff7be0f9c9fae
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f8d2d1abe691947569401c2af3c61d8f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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 = UTF8ToString(connectFacebookUrl);
var localeString = UTF8ToString(locale);
var initParamsString = UTF8ToString(initParams);
FBUnity.init(connectFacebookUrlString, localeString, debug, initParamsString, status);
},
initScreenPosition: function() {
FBUnity.initScreenPosition();
},
login: function(scope, callback_id) {
var scopeString = UTF8ToString(scope);
var scopeArray = JSON.parse(scopeString);
var callback_idString = UTF8ToString(callback_id);
FBUnity.login(scopeArray, callback_idString);
},
activateApp: function() {
FBUnity.activateApp();
},
logout: function() {
FBUnity.logout();
},
logAppEvent: function(eventName, valueToSum, parameters) {
var eventNameString = UTF8ToString(eventName);
var parametersString = UTF8ToString(parameters);
FBUnity.logAppEvent(eventNameString, valueToSum, parametersString);
},
logAppEventWithoutValue: function(eventName, parameters) {
var eventNameString = UTF8ToString(eventName);
var parametersString = UTF8ToString(parameters);
FBUnity.logAppEvent(eventNameString, null, parametersString);
},
logPurchase: function(purchaseAmount, currency, parameters) {
var currencyString = UTF8ToString(currency);
var parametersString = UTF8ToString(parameters);
FBUnity.logPurchase(purchaseAmount, currencyString, parametersString);
},
ui: function(x, uid, callbackMethodName) {
var xString = UTF8ToString(x);
var uidString = UTF8ToString(uid);
var callbackMethodNameString = UTF8ToString(callbackMethodName);
FBUnity.ui(xString, uidString, callbackMethodNameString);
}
};
autoAddDeps(LibraryManager.library, '$FBUnity');
mergeInto(LibraryManager.library, FBUnityLib);

View File

@@ -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:

View File

@@ -0,0 +1,31 @@
fileFormatVersion: 2
guid: c57105322a98c474faf1ce607f20c3f8
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings: {}
- first:
WebGL: WebGL
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f91de43eaa99b480a931ef38d23529b2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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:[18.0.0,19)" />
<androidPackage spec="com.facebook.android:facebook-applinks:[18.0.0,19)" />
<androidPackage spec="com.facebook.android:facebook-login:[18.0.0,19)" />
<androidPackage spec="com.facebook.android:facebook-share:[18.0.0,19)" />
<androidPackage spec="com.facebook.android:facebook-gamingservices:[18.0.0,19)" />
</androidPackages>
<iosPods>
<iosPod name="FBSDKCoreKit_Basics" version="~> 18.0.0" />
<iosPod name="FBSDKCoreKit" version="~> 18.0.0" />
<iosPod name="FBSDKLoginKit" version="~> 18.0.0" />
<iosPod name="FBSDKShareKit" version="~> 18.0.0" />
<iosPod name="FBSDKGamingServicesKit" version="~> 18.0.0" />
</iosPods>
</dependencies>

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1543e5f9bab73423c96b42cab90363ab
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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.

View File

@@ -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:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9ed1da0db808446a9b99a5cb1a1283f2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 14682abc9f885444e95fef32b035b1b8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,38 @@
fileFormatVersion: 2
guid: da9b46f072216483cbeaac2f4e9d66bb
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings: {}
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,38 @@
fileFormatVersion: 2
guid: 9b35acd5ad1cc4ccfa90dd0c76b491e5
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings: {}
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,7 @@
METADATA = {
"maintainers": [
"gaming_unity_sdk",
],
"name": "Windows",
"owner": "gaming_unity_sdk",
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0ff1e8485a73542f8bd713ee729f1d3f
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,98 @@
fileFormatVersion: 2
guid: bb8fba510a20562428ce21dcfe1f9689
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
- first:
'': Any
second:
enabled: 0
settings:
Exclude Editor: 0
Exclude Linux: 1
Exclude Linux64: 1
Exclude LinuxUniversal: 1
Exclude OSXUniversal: 1
Exclude WebGL: 0
Exclude Win: 0
Exclude Win64: 0
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: Windows
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: LinuxUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
WebGL: WebGL
second:
enabled: 1
settings: {}
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 122122c6c86bf4b2f9d41eabd94e08b1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,38 @@
fileFormatVersion: 2
guid: 0a86410f5a5a04673a334c4a41f97586
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings: {}
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: none
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,38 @@
fileFormatVersion: 2
guid: b3c1e011a9c554f5bb77180e0bc78b27
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings: {}
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: none
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,7 @@
METADATA = {
"maintainers": [
"gaming_unity_sdk",
],
"name": "x64",
"owner": "gaming_unity_sdk",
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 40613c081b2ad4b89b0e47c36f8f6583
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,38 @@
fileFormatVersion: 2
guid: 3a4731f40b2014857bb7b166b5a84528
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings: {}
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: none
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,92 @@
fileFormatVersion: 2
guid: 4a90381adadeb104780cdd17fb448eaf
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
- first:
'': Any
second:
enabled: 0
settings:
Exclude Editor: 0
Exclude Linux: 0
Exclude Linux64: 0
Exclude LinuxUniversal: 0
Exclude OSXUniversal: 0
Exclude WebGL: 0
Exclude Win: 1
Exclude Win64: 0
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: x86_64
DefaultValueInitialized: true
OS: Windows
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: None
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Linux
second:
enabled: 1
settings:
CPU: x86
- first:
Standalone: Linux64
second:
enabled: 1
settings:
CPU: x86_64
- first:
Standalone: LinuxUniversal
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: OSXUniversal
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
WebGL: WebGL
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,38 @@
fileFormatVersion: 2
guid: 8a9057360693548d8bd1eab6b23cf7e8
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings: {}
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: none
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,38 @@
fileFormatVersion: 2
guid: d781a1a83968b427c9ce6593594e6006
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings: {}
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: none
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,38 @@
fileFormatVersion: 2
guid: 27559d89b2dc7451189c6617c6106c93
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings: {}
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: none
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,38 @@
fileFormatVersion: 2
guid: 87498102d2bf3434fbaa7609c107eeac
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings: {}
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: none
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,38 @@
fileFormatVersion: 2
guid: 9ff3f4ffe94f04d1f8d1f27bed872260
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings: {}
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: none
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,38 @@
fileFormatVersion: 2
guid: 5389a1bf510a348cfbc5d10ba61370e3
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings: {}
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: none
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c7781fdd4bbc841e5b500a07ae996402
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 8e73c0c874ba242ca9f2604a0c789507
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: none
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 2b2b42fd731974fc4b3515f9af17f144
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: none
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,7 @@
METADATA = {
"maintainers": [
"gaming_unity_sdk",
],
"name": "x86",
"owner": "gaming_unity_sdk",
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 165be5ee3743d401e9b368527984b484
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 663a16a8db59047929f093d6e4db4f46
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: none
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 60bb5ceb2a9084f4fa94352a8ba41fd7
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: none
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 22a27f75e09ca4c1b822cdc28c8fb416
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: none
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: c1d213c80829b40bc87f2d61b296d0e2
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: none
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: c0d53100d69a84965a1c46317e58fca6
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: none
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: ee032c2607fc34cec961ce7785bbbf54
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: none
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 4c17125735b0a497d8b5cac123e2045f
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: none
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 0dd9597a4bea64ced81de3354e2e54e3
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: none
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b8f5b8cf1ba0b48a68d8df528c95a1e2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,66 @@
fileFormatVersion: 2
guid: 516664901472b44fe83b720b195b5b60
PluginImporter:
externalObjects: {}
serializedVersion: 3
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
Android:
enabled: 0
settings:
AndroidLibraryDependee: UnityLibrary
AndroidSharedLibraryType: Executable
CPU: ARMv7
Any:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 0
Editor:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
Linux64:
enabled: 0
settings:
CPU: AnyCPU
OSXUniversal:
enabled: 0
settings:
CPU: AnyCPU
Win:
enabled: 0
settings:
CPU: AnyCPU
Win64:
enabled: 0
settings:
CPU: AnyCPU
WindowsStoreApps:
enabled: 0
settings:
CPU: AnyCPU
iOS:
enabled: 1
settings:
AddToEmbeddedBinaries: false
CPU: AnyCPU
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e60904421c68b4ce0a81bdf4cc62340c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 61e337f04211345e281c2685a9e6c803
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9824ce44b94d5490287fe463a152e875
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,35 @@
// 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.
// An internal header for declaring interfaces for internal methods in the FacebookSDK
// These are INTERNAL APIs that can change without warning and should not be used directly.
#import <Foundation/Foundation.h>
@interface FBSDKSettings(UnityInternal)
+ (NSString *)userAgentSuffix;
+ (void)setUserAgentSuffix:(NSString *)suffix;
@end
@interface FBSDKShareLinkContent (UnityInternal)
// Deprecated parameters for Feed Dialog - for usage with Unity only.
@property (nonatomic, copy) NSDictionary *feedParameters;
@end

View File

@@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: 66952bdb75cae4c348f3d0521da59bfd
timeCreated: 1435164989
licenseType: Pro
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Android:
enabled: 0
settings:
CPU: AnyCPU
Any:
enabled: 0
settings: {}
Editor:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
Linux:
enabled: 0
settings:
CPU: x86
Linux64:
enabled: 0
settings:
CPU: x86_64
OSXIntel:
enabled: 0
settings:
CPU: AnyCPU
OSXIntel64:
enabled: 0
settings:
CPU: AnyCPU
SamsungTV:
enabled: 0
settings:
STV_MODEL: STANDARD_13
Win:
enabled: 0
settings:
CPU: AnyCPU
Win64:
enabled: 0
settings:
CPU: AnyCPU
iOS:
enabled: 1
settings:
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,44 @@
// 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.
#import <UIKit/UIKit.h>
#import "AppDelegateListener.h"
//if we are on a version of unity that has the version number defined use it, otherwise we have added it ourselves in the post build step
#if HAS_UNITY_VERSION_DEF
#include "UnityTrampolineConfigure.h"
#endif
@interface FBUnityInterface : NSObject <AppDelegateListener>
{
//If you make changes in here make the same changes in Assets/Facebook/Scripts/NativeDialogModes.cs
enum ShareDialogMode
{
AUTOMATIC = 0,
NATIVE = 1,
WEB = 2,
FEED = 3,
};
}
@property (assign, nonatomic) BOOL useFrictionlessRequests;
@property (nonatomic) ShareDialogMode shareDialogMode;
+ (FBUnityInterface *)sharedInstance;
@end

View File

@@ -0,0 +1,57 @@
fileFormatVersion: 2
guid: 511e95bcdad89425999ccbb3e315246a
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Android:
enabled: 0
settings:
CPU: AnyCPU
Any:
enabled: 0
settings: {}
Editor:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
Linux:
enabled: 0
settings:
CPU: x86
Linux64:
enabled: 0
settings:
CPU: x86_64
OSXIntel:
enabled: 0
settings:
CPU: AnyCPU
OSXIntel64:
enabled: 0
settings:
CPU: AnyCPU
SamsungTV:
enabled: 0
settings:
STV_MODEL: STANDARD_13
Win:
enabled: 0
settings:
CPU: AnyCPU
Win64:
enabled: 0
settings:
CPU: AnyCPU
iOS:
enabled: 1
settings:
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,949 @@
// 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.
#import <SafariServices/SafariServices.h>
#import <AuthenticationServices/AuthenticationServices.h>
#import <FBSDKCoreKit/FBSDKCoreKit-Swift.h>
#import <FBSDKLoginKit/FBSDKLoginKit-Swift.h>
#import <Foundation/NSJSONSerialization.h>
#include "FBUnityInterface.h"
#include "FBUnitySDKDelegate.h"
#include "FBUnityUtility.h"
#include "FBSDK+Internal.h"
@interface FBUnityInterface()
@property (nonatomic, copy) NSString *openURLString;
@end
@implementation FBUnityInterface
#pragma mark Object Initialization
+ (FBUnityInterface *)sharedInstance
{
static dispatch_once_t pred;
static FBUnityInterface *shared = nil;
dispatch_once(&pred, ^{
shared = [[FBUnityInterface alloc] init];
shared.shareDialogMode = ShareDialogMode::AUTOMATIC;
});
return shared;
}
+ (void)load
{
UnityRegisterAppDelegateListener([FBUnityInterface sharedInstance]);
}
#pragma mark - App (Delegate) Lifecycle
// didBecomeActive: and onOpenURL: are called by Unity's AppController
// because we implement <AppDelegateListener> and registered via UnityRegisterAppDelegateListener(...) above.
- (void)didFinishLaunching:(NSNotification *)notification
{
[[FBSDKApplicationDelegate sharedInstance] application:[UIApplication sharedApplication]
didFinishLaunchingWithOptions:notification.userInfo];
}
- (void)didBecomeActive:(NSNotification *)notification
{
}
- (void)onOpenURL:(NSNotification *)notification
{
NSURL *url = notification.userInfo[@"url"];
BOOL isHandledByFBSDK = [[FBSDKApplicationDelegate sharedInstance] application:[UIApplication sharedApplication]
openURL:url
sourceApplication:notification.userInfo[@"sourceApplication"]
annotation:notification.userInfo[@"annotation"]];
if (!isHandledByFBSDK) {
[FBUnityInterface sharedInstance].openURLString = [url absoluteString];
}
}
#pragma mark - Implementation
- (void)configureAppId:(const char *)appId
frictionlessRequests:(bool)frictionlessRequests
urlSuffix:(const char *)urlSuffix
{
self.useFrictionlessRequests = frictionlessRequests;
if(appId) {
[FBSDKSettings.sharedSettings setAppID:[FBUnityUtility stringFromCString:appId]];
}
if(urlSuffix && strlen(urlSuffix) > 0) {
[FBSDKSettings.sharedSettings setAppURLSchemeSuffix:[FBUnityUtility stringFromCString:urlSuffix]];
}
NSDictionary *userData = [self getAccessTokenUserData] ?: @{};
[FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnInitComplete userData:userData requestId:0];
}
- (void)logInWithPublishPermissions:(int) requestId
scope:(const char *)scope
{
[self startLogin:requestId scope:scope isPublishPermLogin:YES];
}
- (void)logInWithReadPermissions:(int) requestId
scope:(const char *)scope
{
[self startLogin:requestId scope:scope isPublishPermLogin:NO];
}
- (void)startLogin:(int) requestId
scope:(const char *)scope
isPublishPermLogin:(BOOL)isPublishPermLogin
{
NSString *scopeStr = [FBUnityUtility stringFromCString:scope];
NSArray *permissions = nil;
if(scope && strlen(scope) > 0) {
permissions = [scopeStr componentsSeparatedByString:@","];
}
void (^loginHandler)(FBSDKLoginManagerLoginResult *,NSError *) = ^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnLoginComplete error:error requestId:requestId];
return;
} else if (result.isCancelled) {
[FBUnityUtility sendCancelToUnity:FBUnityMessageName_OnLoginComplete requestId:requestId];
return;
}
if ([self tryCompleteLoginWithRequestId:requestId]) {
return;
} else {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnLoginComplete errorMessage:@"Unknown login error" requestId:requestId];
}
};
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithPermissions:permissions
fromViewController:nil
handler:loginHandler];
}
- (void)loginWithTrackingPreference:(int)requestId
scope:(const char *)scope
tracking:(const char *)tracking
nonce:(const char *)nonce
{
NSString *scopeStr = [FBUnityUtility stringFromCString:scope];
NSArray *permissions = nil;
if(scope && strlen(scope) > 0) {
permissions = [scopeStr componentsSeparatedByString:@","];
}
NSString *trackingStr = [FBUnityUtility stringFromCString:tracking];
NSString *nonceStr = nil;
if (nonce) {
nonceStr = [FBUnityUtility stringFromCString:nonce];
}
FBSDKLoginConfiguration *config;
if (nonce) {
config = [[FBSDKLoginConfiguration alloc] initWithPermissions:permissions tracking:([trackingStr isEqualToString:@"enabled"] ? FBSDKLoginTrackingEnabled : FBSDKLoginTrackingLimited) nonce:nonceStr];
} else {
config = [[FBSDKLoginConfiguration alloc] initWithPermissions:permissions tracking:([trackingStr isEqualToString:@"enabled"] ? FBSDKLoginTrackingEnabled : FBSDKLoginTrackingLimited)];
}
void (^loginHandler)(FBSDKLoginManagerLoginResult *,NSError *) = ^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnLoginComplete error:error requestId:requestId];
return;
} else if (result.isCancelled) {
[FBUnityUtility sendCancelToUnity:FBUnityMessageName_OnLoginComplete requestId:requestId];
return;
}
if ([self tryCompleteLoginWithRequestId:requestId]) {
return;
} else {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnLoginComplete errorMessage:@"Unknown login error" requestId:requestId];
}
};
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInFromViewController:nil configuration:config completion:loginHandler];
}
- (void)logOut
{
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logOut];
[FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnLogoutComplete userData:@{} requestId:0];
}
- (void)appRequestWithRequestId:(int)requestId
message:(const char *)message
actionType:(const char *)actionType
objectId:(const char *)objectId
to:(const char **)to
toLength:(int)toLength
filters:(const char *)filters
data:(const char *)data
title:(const char *)title
{
FBSDKGameRequestContent *content = [[FBSDKGameRequestContent alloc] init];
content.message = [FBUnityUtility stringFromCString:message];
content.actionType = [FBUnityUtility gameRequestActionTypeFromString:[FBUnityUtility stringFromCString:actionType]];
content.objectID = [FBUnityUtility stringFromCString:objectId];
if(to && toLength) {
NSMutableArray *toArray = [NSMutableArray array];
for(int i = 0; i < toLength; i++) {
[toArray addObject:[FBUnityUtility stringFromCString:to[i]]];
}
content.recipients = toArray;
}
content.filters = [FBUnityUtility gameRequestFilterFromString:[FBUnityUtility stringFromCString:filters]];
content.data = [FBUnityUtility stringFromCString:data];
content.title = [FBUnityUtility stringFromCString:title];
FBUnitySDKDelegate *delegate = [FBUnitySDKDelegate instanceWithRequestID:requestId];
NSError *error;
FBSDKGameRequestDialog *dialog = [[FBSDKGameRequestDialog alloc] initWithContent:content delegate:delegate];
dialog.isFrictionlessRequestsEnabled = self.useFrictionlessRequests;
if (![dialog validateWithError:&error]) {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnAppRequestsComplete error:error requestId:requestId];
}
if (![dialog show]) {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnAppRequestsComplete errorMessage:@"Failed to show request dialog" requestId:requestId];
}
}
- (void)shareLinkWithRequestId:(int)requestId
contentURL:(const char *)contentURL
contentTitle:(const char *)contentTitle
contentDescription:(const char *)contentDescription
photoURL:(const char *)photoURL
{
FBSDKShareLinkContent *linkContent = [[FBSDKShareLinkContent alloc] init];
NSString *contentUrlStr = [FBUnityUtility stringFromCString:contentURL];
if (contentUrlStr) {
linkContent.contentURL = [NSURL URLWithString:contentUrlStr];
}
[self shareContentWithRequestId:requestId
shareContent:linkContent
dialogMode:[self getDialogMode]];
}
- (void)shareFeedWithRequestId:(int)requestId
toId:(const char *)toID
link:(const char *)link
linkName:(const char *)linkName
linkCaption:(const char *)linkCaption
linkDescription:(const char *)linkDescription
picture:(const char *)picture
mediaSource:(const char *)mediaSource
{
FBSDKShareLinkContent *linkContent = [[FBSDKShareLinkContent alloc] init];
NSString *contentUrlStr = [FBUnityUtility stringFromCString:link];
if (contentUrlStr) {
linkContent.contentURL = [NSURL URLWithString:contentUrlStr];
}
NSMutableDictionary *feedParameters = [[NSMutableDictionary alloc] init];
NSString *toStr = [FBUnityUtility stringFromCString:toID];
if (toStr) {
[feedParameters setObject:toStr forKey:@"to"];
}
NSString *captionStr = [FBUnityUtility stringFromCString:linkCaption];
if (captionStr) {
[feedParameters setObject:captionStr forKey:@"caption"];
}
NSString *sourceStr = [FBUnityUtility stringFromCString:mediaSource];
if (sourceStr) {
[feedParameters setObject:sourceStr forKey:@"source"];
}
[linkContent addParameters:feedParameters bridgeOptions:FBSDKShareBridgeOptionsDefault];
[self shareContentWithRequestId:requestId
shareContent:linkContent
dialogMode:FBSDKShareDialogModeFeedWeb];
}
- (void)shareContentWithRequestId:(int)requestId
shareContent:(FBSDKShareLinkContent *)linkContent
dialogMode:(FBSDKShareDialogMode)dialogMode
{
FBUnitySDKDelegate *delegate = [FBUnitySDKDelegate instanceWithRequestID:requestId];
FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] initWithViewController:nil
content:linkContent
delegate:delegate];
dialog.mode = dialogMode;
NSError *error;
if (![dialog validateWithError:&error]) {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnShareLinkComplete error:error requestId:requestId];
}
if (![dialog show]) {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnShareLinkComplete errorMessage:@"Failed to show share dialog" requestId:requestId];
}
}
- (FBSDKShareDialogMode)getDialogMode
{
switch (self.shareDialogMode) {
case ShareDialogMode::AUTOMATIC:
return FBSDKShareDialogModeAutomatic;
case ShareDialogMode::NATIVE:
return FBSDKShareDialogModeNative;
case ShareDialogMode::WEB:
return FBSDKShareDialogModeWeb;
case ShareDialogMode::FEED:
return FBSDKShareDialogModeFeedWeb;
default:
NSLog(@"Unexpected dialog mode: %@", [NSNumber numberWithInt:self.shareDialogMode]);
return FBSDKShareDialogModeAutomatic;
}
}
- (BOOL)tryCompleteLoginWithRequestId:(int) requestId
{
NSMutableDictionary *userData = [[NSMutableDictionary alloc] init];
NSDictionary *accessTokenUserData = [self getAccessTokenUserData];
NSDictionary *authenticationTokenUserData = [self getAuthenticationTokenUserData];
if (accessTokenUserData) {
[userData addEntriesFromDictionary:accessTokenUserData];
}
if (authenticationTokenUserData) {
[userData addEntriesFromDictionary:authenticationTokenUserData];
}
if (userData) {
[FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnLoginComplete
userData:[userData copy]
requestId:requestId];
return YES;
} else {
return NO;
}
}
- (NSDictionary *)getAccessTokenUserData
{
FBSDKAccessToken *token = [FBSDKAccessToken currentAccessToken];
if (token) {
// Old v3 sdk tokens don't always contain a UserID. If the user ID is null
// treat the token as bad and clear it. These values are all required
// on c# side for initlizing a token.
NSDictionary *userData = [FBUnityUtility getUserDataFromAccessToken:token];
if (userData) {
return userData;
} else {
// The token is missing a required value. Clear the token
[[[FBSDKLoginManager alloc] init] logOut];
}
}
return nil;
}
- (NSDictionary *)getAuthenticationTokenUserData
{
FBSDKAuthenticationToken *token = [FBSDKAuthenticationToken currentAuthenticationToken];
if (token.tokenString && token.nonce) {
return @{
@"auth_token_string": token.tokenString,
@"auth_nonce": token.nonce
};
}
return nil;
}
@end
#pragma mark - Actual Unity C# interface (extern C)
extern "C" {
void IOSFBSendViewHierarchy(const char *_tree )
{
Class FBUnityUtility = NSClassFromString(@"FBSDKCodelessIndexer");
[FBUnityUtility performSelector:NSSelectorFromString(@"uploadIndexing:")
withObject:[NSString stringWithUTF8String:_tree]];
}
void IOSFBInit(const char *_appId, bool _frictionlessRequests, const char *_urlSuffix, const char *_userAgentSuffix)
{
// Set the user agent before calling init to ensure that calls made during
// init use the user agent suffix.
[FBSDKSettings.sharedSettings setUserAgentSuffix:[FBUnityUtility stringFromCString:_userAgentSuffix]];
[[FBUnityInterface sharedInstance] configureAppId:_appId
frictionlessRequests:_frictionlessRequests
urlSuffix:_urlSuffix];
[[FBSDKAppEvents shared] setIsUnityInitialized:true];
[[FBSDKAppEvents shared] sendEventBindingsToUnity];
}
void IOSFBEnableProfileUpdatesOnAccessTokenChange(bool enable)
{
[FBSDKProfile enableUpdatesOnAccessTokenChange:enable];
}
void IOSFBLoginWithTrackingPreference(int requestId, const char *scope, const char *tracking, const char *nonce)
{
[[FBUnityInterface sharedInstance] loginWithTrackingPreference:requestId scope:scope
tracking:tracking
nonce:nonce];
}
void IOSFBLogInWithReadPermissions(int requestId,
const char *scope)
{
[[FBUnityInterface sharedInstance] logInWithReadPermissions:requestId scope:scope];
}
void IOSFBLogInWithPublishPermissions(int requestId,
const char *scope)
{
[[FBUnityInterface sharedInstance] logInWithPublishPermissions:requestId scope:scope];
}
void IOSFBLogOut()
{
[[FBUnityInterface sharedInstance] logOut];
}
char* IOSFBCurrentAuthenticationToken()
{
FBSDKAuthenticationToken *token = [FBSDKAuthenticationToken currentAuthenticationToken];
NSString *str = @"";
if (token.tokenString && token.nonce) {
try {
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:@{
@"auth_token_string": token.tokenString,
@"auth_nonce": token.nonce
} options:NSJSONWritingPrettyPrinted error:nil];
if (jsonData) {
str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
} catch (NSException *exception) {
NSLog(@"Fail to parse AuthenticationToken");
}
}
const char* string = [str UTF8String];
char* res = (char*)malloc(strlen(string) + 1);
strcpy(res, string);
return res;
}
char* IOSFBCurrentProfile()
{
FBSDKProfile *profile = [FBSDKProfile currentProfile];
NSString *str = @"";
NSMutableDictionary<NSString *, id> *data = [NSMutableDictionary new];
if (profile.userID) {
data[@"userID"] = profile.userID;
}
if (profile.firstName) {
data[@"firstName"] = profile.firstName;
}
if (profile.middleName) {
data[@"middleName"] = profile.middleName;
}
if (profile.lastName) {
data[@"lastName"] = profile.lastName;
}
if (profile.name) {
data[@"name"] = profile.name;
}
if (profile.email) {
data[@"email"] = profile.email;
}
if (profile.imageURL) {
data[@"imageURL"] = profile.imageURL.absoluteString;
}
if (profile.linkURL) {
data[@"linkURL"] = profile.linkURL.absoluteString;
}
if (profile.friendIDs) {
data[@"friendIDs"] = [profile.friendIDs componentsJoinedByString:@","];
}
if (profile.birthday) {
data[@"birthday"] = [NSString stringWithFormat:@"%@", @((time_t)[profile.birthday timeIntervalSince1970])];
}
if (profile.ageRange) {
if (profile.ageRange.min) {
data[@"ageMin"] = profile.ageRange.min.stringValue;
}
if (profile.ageRange.max) {
data[@"ageMax"] = profile.ageRange.max.stringValue;
}
}
if (profile.hometown) {
data[@"hometown_id"] = profile.hometown.id;
data[@"hometown_name"] = profile.hometown.name;
}
if (profile.location) {
data[@"location_id"] = profile.location.id;
data[@"location_name"] = profile.location.name;
}
if (profile.gender) {
data[@"gender"] = profile.gender;
}
try {
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:data options:NSJSONWritingPrettyPrinted error:nil];
if (jsonData) {
str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
} catch (NSException *exception) {
NSLog(@"Fail to parse Profile");
}
const char* string = [str UTF8String];
char* res = (char*)malloc(strlen(string) + 1);
strcpy(res, string);
return res;
}
void IOSFBSetPushNotificationsDeviceTokenString(const char *token)
{
[[FBSDKAppEvents shared] setPushNotificationsDeviceTokenString:[FBUnityUtility stringFromCString:token]];
}
void IOSFBSetShareDialogMode(int mode)
{
[FBUnityInterface sharedInstance].shareDialogMode = static_cast<ShareDialogMode>(mode);
}
void IOSFBAppRequest(int requestId,
const char *message,
const char *actionType,
const char *objectId,
const char **to,
int toLength,
const char *filters,
const char **excludeIds, //not supported on mobile
int excludeIdsLength, //not supported on mobile
bool hasMaxRecipients, //not supported on mobile
int maxRecipients, //not supported on mobile
const char *data,
const char *title)
{
[[FBUnityInterface sharedInstance] appRequestWithRequestId: requestId
message: message
actionType: actionType
objectId: objectId
to: to
toLength: toLength
filters: filters
data: data
title: title];
}
void IOSFBGetAppLink(int requestId)
{
NSURL *url = [NSURL URLWithString:[FBUnityInterface sharedInstance].openURLString];
[FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnGetAppLinkComplete
userData:[FBUnityUtility appLinkDataFromUrl:url]
requestId:requestId];
[FBUnityInterface sharedInstance].openURLString = nil;
}
void IOSFBShareLink(int requestId,
const char *contentURL,
const char *contentTitle,
const char *contentDescription,
const char *photoURL)
{
[[FBUnityInterface sharedInstance] shareLinkWithRequestId:requestId
contentURL:contentURL
contentTitle:contentTitle
contentDescription:contentDescription
photoURL:photoURL];
}
void IOSFBFeedShare(int requestId,
const char *toId,
const char *link,
const char *linkName,
const char *linkCaption,
const char *linkDescription,
const char *picture,
const char *mediaSource)
{
[[FBUnityInterface sharedInstance] shareFeedWithRequestId:requestId
toId:toId
link:link
linkName:linkName
linkCaption:linkCaption
linkDescription:linkDescription
picture:picture
mediaSource:mediaSource];
}
void IOSFBAppEventsActivateApp()
{
[FBSDKAppEvents.shared activateApp];
}
void IOSFBAppEventsLogEvent(const char *eventName,
double valueToSum,
int numParams,
const char **paramKeys,
const char **paramVals)
{
NSDictionary *params = [FBUnityUtility dictionaryFromKeys:paramKeys values:paramVals length:numParams];
[[FBSDKAppEvents shared] logEvent:[FBUnityUtility stringFromCString:eventName] valueToSum:valueToSum parameters:params];
}
void IOSFBAppEventsLogPurchase(double amount,
const char *currency,
int numParams,
const char **paramKeys,
const char **paramVals)
{
NSDictionary *params = [FBUnityUtility dictionaryFromKeys:paramKeys values:paramVals length:numParams];
[[FBSDKAppEvents shared] logPurchase:amount currency:[FBUnityUtility stringFromCString:currency] parameters:params];
}
void IOSFBAppEventsSetLimitEventUsage(BOOL limitEventUsage)
{
[FBSDKSettings.sharedSettings setIsEventDataUsageLimited:limitEventUsage];
}
void IOSFBAutoLogAppEventsEnabled(BOOL autoLogAppEventsEnabledID)
{
[FBSDKSettings.sharedSettings setAutoLogAppEventsEnabled:autoLogAppEventsEnabledID];
}
void IOSFBAdvertiserIDCollectionEnabled(BOOL advertiserIDCollectionEnabledID)
{
[FBSDKSettings.sharedSettings setAdvertiserIDCollectionEnabled:advertiserIDCollectionEnabledID];
}
BOOL IOSFBAdvertiserTrackingEnabled(BOOL advertiserTrackingEnabled)
{
[FBSDKSettings.sharedSettings setAdvertiserTrackingEnabled:advertiserTrackingEnabled];
return [FBSDKSettings.sharedSettings isAdvertiserTrackingEnabled];
}
BOOL IOSFBDomainErrorEnabled(BOOL domainErrorEnabled)
{
[FBSDKSettings.sharedSettings setIsDomainErrorEnabled:domainErrorEnabled];
return [FBSDKSettings.sharedSettings isDomainErrorEnabled];
}
char* IOSFBSdkVersion()
{
const char* string = [[FBSDKSettings.sharedSettings sdkVersion] UTF8String];
char* res = (char*)malloc(strlen(string) + 1);
strcpy(res, string);
return res;
}
void IOSFBSetUserID(const char *userID)
{
[[FBSDKAppEvents shared] setUserID:[FBUnityUtility stringFromCString:userID]];
}
void IOSFBOpenGamingServicesFriendFinder(int requestId)
{
[FBSDKFriendFinderDialog
launchFriendFinderDialogWithCompletionHandler:^(BOOL success, NSError * _Nullable error) {
if (!success || error) {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnFriendFinderComplete error:error requestId:requestId];
} else {
[FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnFriendFinderComplete
userData:NULL
requestId:requestId];
}
}];
}
void IOSFBCreateGamingContext(int requestID, const char *playerID) {
NSError *error;
NSString *playerIDString = [FBUnityUtility stringFromCString:playerID];
FBUnitySDKDelegate *delegate = [FBUnitySDKDelegate instanceWithRequestID:requestID];
FBSDKCreateContextContent *content = [[FBSDKCreateContextContent alloc] initDialogContentWithPlayerID:playerIDString];
FBSDKContextDialogPresenter *presenter = [[FBSDKContextDialogPresenter alloc] init];
[presenter makeAndShowCreateContextDialogWithContent:content delegate:delegate error:&error];
if (error) {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnGetTournamentsComplete error:error requestId:requestID];
}
}
void IOSFBSwitchGamingContext(
int requestID,
const char *contextID) {
NSError *error;
NSString *contextIDString = [FBUnityUtility stringFromCString:contextID];
FBUnitySDKDelegate *delegate = [FBUnitySDKDelegate instanceWithRequestID:requestID];
FBSDKSwitchContextContent *content = [[FBSDKSwitchContextContent alloc] initDialogContentWithContextID:contextIDString];
FBSDKContextDialogPresenter *presenter = [[FBSDKContextDialogPresenter alloc] init];
[presenter makeAndShowSwitchContextDialogWithContent:content delegate:delegate error:&error];
if (error) {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnGetTournamentsComplete error:error requestId:requestID];
}
}
void IOSFBChooseGamingContext(
int requestID,
const char *filter,
int minSize,
int maxSize)
{
FBUnitySDKDelegate *delegate = [FBUnitySDKDelegate instanceWithRequestID:requestID];
FBSDKChooseContextContent *chooseContent = [FBSDKChooseContextContent alloc];
NSString *filterNSString = [NSString stringWithUTF8String:filter];
if ([filterNSString length] == 0) {
chooseContent.filter = FBSDKChooseContextFilterNone;
} else if ([filterNSString isEqualToString:@"NEW_PLAYERS_ONLY"]) {
chooseContent.filter = FBSDKChooseContextFilterNewPlayersOnly;
} else if ([filterNSString isEqualToString:@"INCLUDE_EXISTING_CHALLENGES"]) {
chooseContent.filter = FBSDKChooseContextFilterExistingChallenges;
} else if ([filterNSString isEqualToString:@"NEW_CONTEXT_ONLY"]) {
chooseContent.filter = FBSDKChooseContextFilterNewContextOnly;
}
if (minSize > 0) {
chooseContent.minParticipants = minSize;
}
if (maxSize > 0) {
chooseContent.maxParticipants = maxSize;
}
FBSDKContextDialogPresenter *presenter = [[FBSDKContextDialogPresenter alloc] init];
[presenter makeAndShowChooseContextDialogWithContent:chooseContent delegate:delegate];
}
void IOSFBGetCurrentGamingContext(int requestID)
{
FBSDKGamingContext *currentContext = [FBSDKGamingContext currentContext];
if (currentContext) {
[FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnGetCurrentGamingContextComplete
userData:@{@"contextId":[currentContext identifier]}
requestId:requestID];
} else {
[FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnGetCurrentGamingContextComplete
userData:NULL
requestId:requestID];
}
}
void IOSFBSetDataProcessingOptions(
const char** options,
int numOptions,
int country,
int state) {
NSMutableArray<NSString*>* array = [[NSMutableArray alloc] init];
for (int i = 0; i < numOptions; i++) {
NSString* option = [FBUnityUtility stringFromCString:options[i]];
if (option) {
[array addObject:option];
}
}
[FBSDKSettings.sharedSettings setDataProcessingOptions:array country:country state:state];
}
void IOSFBGetTournaments(int requestID)
{
FBSDKTournamentFetcher *fetcher = [[FBSDKTournamentFetcher alloc] init];
[fetcher fetchTournamentsWithCompletionHandler:^(NSArray<FBSDKTournament *> * tournaments, NSError * error) {
if (error) {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnGetTournamentsComplete error:error requestId:requestID];
}
NSMutableDictionary *userData = [NSMutableDictionary new];
for (FBSDKTournament *tournament in tournaments) {
userData[tournament.identifier] = [tournament toDictionary];
}
[FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnGetTournamentsComplete
userData:userData
requestId:requestID];
}];
}
void IOSFBUpdateTournament(const char *tournamentID, int score, int requestID)
{
FBSDKTournamentUpdater *updater = [[FBSDKTournamentUpdater alloc] init];
[updater updateWithTournamentID:[NSString stringWithUTF8String:tournamentID]
score:score
completionHandler:^(BOOL success, NSError * _Nullable error) {
if (!success || error) {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnUpdateTournamentComplete error:error requestId:requestID];
} else {
[FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnUpdateTournamentComplete
userData:NULL
requestId:requestID];
}
}];
}
void IOSFBUpdateAndShareTournament(const char *tournamentID, int score, int requestID)
{
NSError *error;
FBUnitySDKDelegate *delegate = [FBUnitySDKDelegate instanceWithRequestID:requestID];
FBSDKShareTournamentDialog *dialog = [[FBSDKShareTournamentDialog alloc] initWithDelegate: delegate];
[dialog showWithScore:score tournamentID:[NSString stringWithUTF8String:tournamentID] error:&error];
if (error) {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnGetTournamentsComplete error:error requestId:requestID];
}
}
void IOSFBCreateAndShareTournament(
int initialScore,
const char *title,
int sortOrder,
int scoreFormat,
long endTime,
const char *payload,
int requestID)
{
NSError *error;
FBUnitySDKDelegate *delegate = [FBUnitySDKDelegate instanceWithRequestID:requestID];
FBSDKShareTournamentDialog *dialog = [[FBSDKShareTournamentDialog alloc] initWithDelegate: delegate];
NSString *payloadString;
if (payload) {
payloadString = [NSString stringWithUTF8String:payload];
}
[dialog showWithInitialScore:initialScore
title:[NSString stringWithUTF8String:title]
endTime:[NSDate dateWithTimeIntervalSince1970: endTime]
scoreType:scoreFormat
sortOrder:sortOrder
payload:payloadString
error: &error];
if (error) {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnGetTournamentsComplete error:error requestId:requestID];
}
}
void IOSFBUploadImageToMediaLibrary(
int requestId,
const char *caption,
const char *imageUri,
bool shouldLaunchMediaDialog)
{
NSString *captionString = [FBUnityUtility stringFromCString:caption];
NSString *imageUriString = [FBUnityUtility stringFromCString:imageUri];
UIImage *image = [UIImage imageWithContentsOfFile:imageUriString];
FBSDKGamingImageUploaderConfiguration *config =
[[FBSDKGamingImageUploaderConfiguration alloc]
initWithImage:image
caption:captionString
shouldLaunchMediaDialog:shouldLaunchMediaDialog ? YES: NO];
[FBSDKGamingImageUploader
uploadImageWithConfiguration:config
andResultCompletion:^(BOOL success, id result, NSError * _Nullable error) {
if (!success || error) {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnUploadImageToMediaLibraryComplete
error:error
requestId:requestId];
} else {
[FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnUploadImageToMediaLibraryComplete
userData:@{@"id":result[@"id"]}
requestId:requestId];
}
}];
}
void IOSFBUploadVideoToMediaLibrary(int requestId,
const char *caption,
const char *videoUri)
{
NSString *captionString = [FBUnityUtility stringFromCString:caption];
NSString *videoUriString = [FBUnityUtility stringFromCString:videoUri];
NSURL *videoURL = [NSURL fileURLWithPath:videoUriString];
FBSDKGamingVideoUploaderConfiguration *config =
[[FBSDKGamingVideoUploaderConfiguration alloc]
initWithVideoURL:videoURL
caption:captionString];
[FBSDKGamingVideoUploader
uploadVideoWithConfiguration:config
andResultCompletion:^(BOOL success, id result, NSError * _Nullable error) {
if (!success || error) {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnUploadVideoToMediaLibraryComplete
error:error
requestId:requestId];
} else {
[FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnUploadVideoToMediaLibraryComplete
userData:@{@"id":result[@"id"]}
requestId:requestId];
}
}];
}
char* IOSFBGetUserID()
{
NSString *userID = [[FBSDKAppEvents shared] userID];
if (!userID) {
return NULL;
}
const char* string = [userID UTF8String];
char* res = (char*)malloc(strlen(string) + 1);
strcpy(res, string);
return res;
}
void IOSFBFetchDeferredAppLink(int requestId)
{
[FBSDKAppLinkUtility fetchDeferredAppLink:^(NSURL *url, NSError *error) {
if (error) {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnFetchDeferredAppLinkComplete error:error requestId:requestId];
return;
}
[FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnFetchDeferredAppLinkComplete
userData:[FBUnityUtility appLinkDataFromUrl:url]
requestId:requestId];
}];
}
void IOSFBRefreshCurrentAccessToken(int requestId)
{
FBSDKGraphRequestCompletion completion = ^(id<FBSDKGraphRequestConnecting> connection, id result, NSError *error) {
if (error) {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnRefreshCurrentAccessTokenComplete error:error requestId:requestId];
return;
}
[FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnRefreshCurrentAccessTokenComplete
userData:[FBUnityUtility getUserDataFromAccessToken:[FBSDKAccessToken currentAccessToken]]
requestId:requestId];
};
[FBSDKAccessToken refreshCurrentAccessTokenWithCompletion: completion];
}
}

View File

@@ -0,0 +1,57 @@
fileFormatVersion: 2
guid: 4c29c5d59509848c4bc24c13ac976932
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Android:
enabled: 0
settings:
CPU: AnyCPU
Any:
enabled: 0
settings: {}
Editor:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
Linux:
enabled: 0
settings:
CPU: x86
Linux64:
enabled: 0
settings:
CPU: x86_64
OSXIntel:
enabled: 0
settings:
CPU: AnyCPU
OSXIntel64:
enabled: 0
settings:
CPU: AnyCPU
SamsungTV:
enabled: 0
settings:
STV_MODEL: STANDARD_13
Win:
enabled: 0
settings:
CPU: AnyCPU
Win64:
enabled: 0
settings:
CPU: AnyCPU
iOS:
enabled: 1
settings:
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,63 @@
// 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.
#import <AVFoundation/AVFoundation.h>
#import <FBSDKShareKit/FBSDKShareKit-Swift.h>
#import <FBSDKGamingServicesKit/FBSDKGamingServicesKit-Swift.h>
#import <UnityFramework/UnityFramework-Swift.h>
extern NSString *const FBUnityMessageName_OnAppRequestsComplete;
extern NSString *const FBUnityMessageName_OnFriendFinderComplete;
extern NSString *const FBUnityMessageName_OnGetAppLinkComplete;
extern NSString *const FBUnityMessageName_OnGroupCreateComplete;
extern NSString *const FBUnityMessageName_OnGroupJoinComplete;
extern NSString *const FBUnityMessageName_OnInitComplete;
extern NSString *const FBUnityMessageName_OnLoginComplete;
extern NSString *const FBUnityMessageName_OnLogoutComplete;
extern NSString *const FBUnityMessageName_OnShareLinkComplete;
extern NSString *const FBUnityMessageName_OnFetchDeferredAppLinkComplete;
extern NSString *const FBUnityMessageName_OnRefreshCurrentAccessTokenComplete;
extern NSString *const FBUnityMessageName_OnUploadImageToMediaLibraryComplete;
extern NSString *const FBUnityMessageName_OnUploadVideoToMediaLibraryComplete;
extern NSString *const FBUnityMessageName_OnCreateGamingContextComplete;
extern NSString *const FBUnityMessageName_OnSwitchGamingContextComplete;
extern NSString *const FBUnityMessageName_OnChooseGamingContextComplete;
extern NSString *const FBUnityMessageName_OnGetCurrentGamingContextComplete;
extern NSString *const FBUnityMessageName_OnGetTournamentsComplete;
extern NSString *const FBUnityMessageName_OnUpdateTournamentComplete;
extern NSString *const FBUnityMessageName_OnTournamentDialogSuccess;
extern NSString *const FBUnityMessageName_OnTournamentDialogCancel;
extern NSString *const FBUnityMessageName_OnTournamentDialogError;
/*!
@abstract A helper class that implements various FBSDK delegates in order to send
messages back to Unity.
*/
@interface FBUnitySDKDelegate : NSObject<
FBSDKGameRequestDialogDelegate,
FBSDKSharingDelegate,
FBSDKContextDialogDelegate,
FBSDKShareTournamentDialogDelegate>
/*
@abstract returns a self retaining instance that is released once it receives a
delegate message from FBSDK.
*/
+ (instancetype)instanceWithRequestID:(int)requestID;
@end

View File

@@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: 7461bcc2e2c714a03a3f60d68ec79369
timeCreated: 1435007350
licenseType: Pro
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Android:
enabled: 0
settings:
CPU: AnyCPU
Any:
enabled: 0
settings: {}
Editor:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
Linux:
enabled: 0
settings:
CPU: x86
Linux64:
enabled: 0
settings:
CPU: x86_64
OSXIntel:
enabled: 0
settings:
CPU: AnyCPU
OSXIntel64:
enabled: 0
settings:
CPU: AnyCPU
SamsungTV:
enabled: 0
settings:
STV_MODEL: STANDARD_13
Win:
enabled: 0
settings:
CPU: AnyCPU
Win64:
enabled: 0
settings:
CPU: AnyCPU
iOS:
enabled: 1
settings:
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,172 @@
// 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.
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import "FBUnitySDKDelegate.h"
#import "FBUnityUtility.h"
NSString *const FBUnityMessageName_OnAppRequestsComplete = @"OnAppRequestsComplete";
NSString *const FBUnityMessageName_OnGetAppLinkComplete = @"OnGetAppLinkComplete";
NSString *const FBUnityMessageName_OnFriendFinderComplete = @"OnFriendFinderComplete";
NSString *const FBUnityMessageName_OnGroupCreateComplete = @"OnGroupCreateComplete";
NSString *const FBUnityMessageName_OnGroupJoinComplete = @"OnGroupJoinComplete";
NSString *const FBUnityMessageName_OnInitComplete = @"OnInitComplete";
NSString *const FBUnityMessageName_OnLoginComplete = @"OnLoginComplete";
NSString *const FBUnityMessageName_OnLogoutComplete = @"OnLogoutComplete";
NSString *const FBUnityMessageName_OnShareLinkComplete = @"OnShareLinkComplete";
NSString *const FBUnityMessageName_OnFetchDeferredAppLinkComplete = @"OnFetchDeferredAppLinkComplete";
NSString *const FBUnityMessageName_OnRefreshCurrentAccessTokenComplete = @"OnRefreshCurrentAccessTokenComplete";
NSString *const FBUnityMessageName_OnUploadImageToMediaLibraryComplete = @"OnUploadImageToMediaLibraryComplete";
NSString *const FBUnityMessageName_OnUploadVideoToMediaLibraryComplete = @"OnUploadVideoToMediaLibraryComplete";
NSString *const FBUnityMessageName_OnCreateGamingContextComplete = @"OnCreateGamingContextComplete";
NSString *const FBUnityMessageName_OnSwitchGamingContextComplete = @"OnSwitchGamingContextComplete";
NSString *const FBUnityMessageName_OnChooseGamingContextComplete = @"OnChooseGamingContextComplete";
NSString *const FBUnityMessageName_OnGetCurrentGamingContextComplete = @"OnGetCurrentGamingContextComplete";
NSString *const FBUnityMessageName_OnGetTournamentsComplete = @"OnGetTournamentsComplete";
NSString *const FBUnityMessageName_OnUpdateTournamentComplete = @"OnUpdateTournamentComplete";
NSString *const FBUnityMessageName_OnTournamentDialogSuccess = @"OnTournamentDialogSuccess";
NSString *const FBUnityMessageName_OnTournamentDialogCancel = @"OnTournamentDialogCancel";
NSString *const FBUnityMessageName_OnTournamentDialogError = @"OnTournamentDialogError";
static NSMutableArray *g_instances;
@implementation FBUnitySDKDelegate {
int _requestID;
}
+ (void)initialize
{
if (self == [FBUnitySDKDelegate class]) {
g_instances = [NSMutableArray array];
}
}
+ (instancetype)instanceWithRequestID:(int)requestID
{
FBUnitySDKDelegate *instance = [[FBUnitySDKDelegate alloc] init];
instance->_requestID = requestID;
[g_instances addObject:instance];
return instance;
}
#pragma mark - Private helpers
- (void)complete
{
[g_instances removeObject:self];
}
#pragma mark - GameRequestDelegate
- (void)gameRequestDialog:(FBSDKGameRequestDialog *)gameRequestDialog didCompleteWithResults:(NSDictionary *)results
{
[FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnAppRequestsComplete userData:results requestId:_requestID];
[self complete];
}
- (void)gameRequestDialog:(FBSDKGameRequestDialog *)gameRequestDialog didFailWithError:(NSError *)error
{
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnAppRequestsComplete error:error requestId:_requestID];
[self complete];
}
- (void)gameRequestDialogDidCancel:(FBSDKGameRequestDialog *)gameRequestDialog
{
[FBUnityUtility sendCancelToUnity:FBUnityMessageName_OnAppRequestsComplete requestId:_requestID];
[self complete];
}
#pragma mark - FBSDKSharingDelegate
- (void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results
{
if (results.count == 0) {
// We no longer always send back a postId. In cases where the response is empty,
// stuff in a didComplete so that Unity doesn't treat it as a malformed response.
results = @{ @"didComplete" : @"1" };
}
[FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnShareLinkComplete userData:results requestId:_requestID];
[self complete];
}
- (void)sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error
{
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnShareLinkComplete error:error requestId:_requestID];
[self complete];
}
- (void)sharerDidCancel:(id<FBSDKSharing>)sharer
{
[FBUnityUtility sendCancelToUnity:FBUnityMessageName_OnShareLinkComplete requestId:_requestID];
[self complete];
}
#pragma mark - FBSDKContextDialogDelegate
- (void)contextDialogDidComplete:(NSObject<FBSDKContextDialogDelegate>*)contextDialog;
{
if ([contextDialog isKindOfClass:[FBSDKChooseContextDialog class]]) {
[FBUnityUtility sendMessageToUnity: FBUnityMessageName_OnChooseGamingContextComplete userData: NULL requestId:_requestID];
} else if ([contextDialog isKindOfClass:[FBSDKSwitchContextDialog class]]) {
[FBUnityUtility sendMessageToUnity: FBUnityMessageName_OnSwitchGamingContextComplete userData: NULL requestId:_requestID];
} else if ([contextDialog isKindOfClass:[FBSDKCreateContextDialog class]]) {
[FBUnityUtility sendMessageToUnity: FBUnityMessageName_OnCreateGamingContextComplete userData: NULL requestId:_requestID];
}
[self complete];
}
- (void)contextDialog:(NSObject<FBSDKContextDialogDelegate>*)contextDialog didFailWithError:(NSError *)error
{
if ([contextDialog isKindOfClass:[FBSDKChooseContextDialog class]]) {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnChooseGamingContextComplete error:error requestId:_requestID];
} else if ([contextDialog isKindOfClass:[FBSDKSwitchContextDialog class]]) {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnSwitchGamingContextComplete error:error requestId:_requestID];
} else if ([contextDialog isKindOfClass:[FBSDKCreateContextDialog class]]) {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnCreateGamingContextComplete error:error requestId:_requestID];
}
[self complete];
}
- (void)contextDialogDidCancel:(NSObject<FBSDKContextDialogDelegate>*)contextDialog
{
if ([contextDialog isKindOfClass:[FBSDKChooseContextDialog class]]) {
[FBUnityUtility sendCancelToUnity:FBUnityMessageName_OnChooseGamingContextComplete requestId:_requestID];
} else if ([contextDialog isKindOfClass:[FBSDKSwitchContextDialog class]]) {
[FBUnityUtility sendCancelToUnity:FBUnityMessageName_OnSwitchGamingContextComplete requestId:_requestID];
} else if ([contextDialog isKindOfClass:[FBSDKCreateContextDialog class]]) {
[FBUnityUtility sendCancelToUnity:FBUnityMessageName_OnCreateGamingContextComplete requestId:_requestID];
}
[self complete];
}
#pragma mark - FBSDKShareTournamentDialogDelegate
- (void)didCancelWithDialog:(FBSDKShareTournamentDialog * _Nonnull)dialog {
[FBUnityUtility sendCancelToUnity:FBUnityMessageName_OnTournamentDialogCancel requestId:_requestID];
}
- (void)didCompleteWithDialog:(FBSDKShareTournamentDialog * _Nonnull)dialog tournament:(FBSDKTournament * _Nonnull)tournament {
[FBUnityUtility sendMessageToUnity: FBUnityMessageName_OnTournamentDialogSuccess userData: [tournament toDictionary] requestId:_requestID];
}
- (void)didFailWithError:(NSError * _Nonnull)error dialog:(FBSDKShareTournamentDialog * _Nonnull)dialog {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnTournamentDialogError error:error requestId:_requestID];
}
@end

View File

@@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: fbc51482e3ca248329707d61959f9d9d
timeCreated: 1435010266
licenseType: Pro
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Android:
enabled: 0
settings:
CPU: AnyCPU
Any:
enabled: 0
settings: {}
Editor:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
Linux:
enabled: 0
settings:
CPU: x86
Linux64:
enabled: 0
settings:
CPU: x86_64
OSXIntel:
enabled: 0
settings:
CPU: AnyCPU
OSXIntel64:
enabled: 0
settings:
CPU: AnyCPU
SamsungTV:
enabled: 0
settings:
STV_MODEL: STANDARD_13
Win:
enabled: 0
settings:
CPU: AnyCPU
Win64:
enabled: 0
settings:
CPU: AnyCPU
iOS:
enabled: 1
settings:
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,37 @@
// 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.
#import <AVFoundation/AVFoundation.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
#import <FBSDKShareKit/FBSDKShareKit-Swift.h>
#import <FBSDKGamingServicesKit/FBSDKGamingServicesKit-Swift.h>
extern const char* const FB_OBJECT_NAME;
@interface FBUnityUtility : NSObject
+ (NSDictionary *)dictionaryFromKeys:(const char **)keys values:(const char **)vals length:(int)length;
+ (FBSDKGameRequestFilter)gameRequestFilterFromString:(NSString *)filter;
+ (FBSDKGameRequestActionType)gameRequestActionTypeFromString:(NSString *)actionType;
+ (void)sendCancelToUnity:(NSString *)unityMessage requestId:(int)requestId;
+ (void)sendErrorToUnity:(NSString *)unityMessage error:(NSError *)error requestId:(int)requestId;
+ (void)sendErrorToUnity:(NSString *)unityMessage errorMessage:(NSString *)errorMessage requestId:(int)requestId;
+ (void)sendMessageToUnity:(NSString *)unityMessage userData:(NSDictionary *)userData requestId:(int)requestId;
+ (NSString *)stringFromCString:(const char *)string;
+ (NSDictionary *)appLinkDataFromUrl:(NSURL *)url;
+ (NSDictionary *)getUserDataFromAccessToken:(FBSDKAccessToken *)token;
@end

View File

@@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: b4469d6625a664618b68231ee0dcc093
timeCreated: 1435010266
licenseType: Pro
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Android:
enabled: 0
settings:
CPU: AnyCPU
Any:
enabled: 0
settings: {}
Editor:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
Linux:
enabled: 0
settings:
CPU: x86
Linux64:
enabled: 0
settings:
CPU: x86_64
OSXIntel:
enabled: 0
settings:
CPU: AnyCPU
OSXIntel64:
enabled: 0
settings:
CPU: AnyCPU
SamsungTV:
enabled: 0
settings:
STV_MODEL: STANDARD_13
Win:
enabled: 0
settings:
CPU: AnyCPU
Win64:
enabled: 0
settings:
CPU: AnyCPU
iOS:
enabled: 1
settings:
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,228 @@
// 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.
#import "FBUnityUtility.h"
#include <string>
#import <Foundation/Foundation.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
#import <FBSDKShareKit/FBSDKShareKit.h>
const char* const FB_OBJECT_NAME = "UnityFacebookSDKPlugin";
// Helper method to create C string copy
static char* FBUnityMakeStringCopy (const char* string)
{
if (string == NULL)
return NULL;
char* res = (char*)malloc(strlen(string) + 1);
strcpy(res, string);
return res;
}
@implementation FBUnityUtility
+ (void) sendCancelToUnity:(NSString *)unityMessage
requestId:(int)requestId
{
[self sendMessageToUnity:unityMessage
userData:@{ @"cancelled" : @"true" }
requestId:requestId];
}
+ (void) triggerUploadViewHierarchy
{
[self sendMessageToUnity:@"CaptureViewHierarchy"
userData:nil
requestId:0];
}
+ (void) triggerUpdateBindings:(NSString *)json
{
[self sendMessageToUnity:@"OnReceiveMapping"
message:json
requestId:0];
}
+ (void)sendErrorToUnity:(NSString *)unityMessage
error:(NSError *)error
requestId:(int)requestId
{
NSString *errorMessage =
error.userInfo[FBSDKErrorLocalizedDescriptionKey] ?:
error.userInfo[FBSDKErrorDeveloperMessageKey] ?:
error.localizedDescription;
[self sendErrorToUnity:unityMessage
errorMessage:errorMessage
requestId:requestId];
}
+ (void)sendErrorToUnity:(NSString *)unityMessage
errorMessage:(NSString *)errorMessage
requestId:(int)requestId
{
[self sendMessageToUnity:unityMessage
userData:@{ @"error" : errorMessage }
requestId:requestId];
}
+ (void)sendMessageToUnity:(NSString *)unityMessage
userData:(NSDictionary *)userData
requestId:(int)requestId
{
NSMutableDictionary *resultDictionary = [ @{ @"callback_id": [@(requestId) stringValue] } mutableCopy];
[resultDictionary addEntriesFromDictionary:userData];
if (![NSJSONSerialization isValidJSONObject:resultDictionary]) {
[self sendErrorToUnity:unityMessage errorMessage:@"Result cannot be converted to json" requestId:requestId];
return;
}
NSError *serializationError = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:resultDictionary options:0 error:&serializationError];
if (serializationError) {
[self sendErrorToUnity:unityMessage error:serializationError requestId:requestId];
return;
}
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
if (!jsonString) {
[self sendErrorToUnity:unityMessage errorMessage:@"Failed to generate response string" requestId:requestId];
return;
}
const char *cString = [jsonString UTF8String];
UnitySendMessage(FB_OBJECT_NAME, [unityMessage cStringUsingEncoding:NSASCIIStringEncoding], FBUnityMakeStringCopy(cString));
}
+ (void)sendMessageToUnity:(NSString *)unityMessage
message:(NSString *)message
requestId:(int)requestId
{
const char *cString = [message UTF8String];
UnitySendMessage(FB_OBJECT_NAME, [unityMessage cStringUsingEncoding:NSASCIIStringEncoding], FBUnityMakeStringCopy(cString));
}
+ (NSString *)stringFromCString:(const char *)string {
if (string && string[0] != 0) {
return [NSString stringWithUTF8String:string];
}
return nil;
}
+ (NSDictionary *)dictionaryFromKeys:(const char **)keys
values:(const char **)vals
length:(int)length
{
NSMutableDictionary *params = nil;
if(length > 0 && keys && vals) {
params = [NSMutableDictionary dictionaryWithCapacity:length];
for(int i = 0; i < length; i++) {
if (vals[i] && vals[i] != 0 && keys[i] && keys[i] != 0) {
params[[NSString stringWithUTF8String:keys[i]]] = [NSString stringWithUTF8String:vals[i]];
}
}
}
return params;
}
+ (FBSDKGameRequestFilter) gameRequestFilterFromString:(NSString *)filter {
if (filter.length == 0 || [filter isEqualToString:@"none"]) {
return FBSDKGameRequestFilterNone;
} else if ([filter isEqualToString:@"app_users"]) {
return FBSDKGameRequestFilterAppUsers;
} else if ([filter isEqualToString:@"app_non_users"]) {
return FBSDKGameRequestFilterAppNonUsers;
}
NSLog(@"Unexpected filter type: %@", filter);
return FBSDKGameRequestFilterNone;
}
+ (FBSDKGameRequestActionType) gameRequestActionTypeFromString:(NSString *)actionType {
NSString *actionUpper = [actionType uppercaseString];
if (actionUpper.length == 0 || [actionUpper isEqualToString:@"NONE"]) {
return FBSDKGameRequestActionTypeNone;
} else if ([actionUpper isEqualToString:@"SEND"]) {
return FBSDKGameRequestActionTypeSend;
} else if ([actionUpper isEqualToString:@"ASKFOR"]) {
return FBSDKGameRequestActionTypeAskFor;
} else if ([actionUpper isEqualToString:@"TURN"]) {
return FBSDKGameRequestActionTypeTurn;
}
NSLog(@"Unexpected action type: %@", actionType);
return FBSDKGameRequestActionTypeNone;
}
+ (NSDictionary *)appLinkDataFromUrl:(NSURL *)url
{
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
if (url) {
[dict setObject:url.absoluteString forKey:@"url"];
FBSDKURL *parsedUrl = [FBSDKURL URLWithInboundURL:url sourceApplication:nil];
if (parsedUrl) {
if (parsedUrl.appLinkExtras) {
[dict setObject:parsedUrl.appLinkExtras forKey:@"extras"];
// TODO - Try to parse ref param out and pass back
}
if (parsedUrl.targetURL) {
[dict setObject:parsedUrl.targetURL.absoluteString forKey:@"target_url"];
}
}
} else {
[dict setObject:@true forKey:@"did_complete"];
}
return dict;
}
+ (NSDictionary *)getUserDataFromAccessToken:(FBSDKAccessToken *)token
{
if (token) {
if (token.tokenString &&
token.expirationDate &&
token.userID &&
token.permissions &&
token.declinedPermissions) {
NSInteger expiration = token.expirationDate.timeIntervalSince1970;
NSInteger lastRefreshDate = token.refreshDate ? token.refreshDate.timeIntervalSince1970 : 0;
return @{
@"opened" : @"true",
@"access_token" : token.tokenString,
@"expiration_timestamp" : [@(expiration) stringValue],
@"user_id" : token.userID,
@"permissions" : [token.permissions allObjects],
@"granted_permissions" : [token.permissions allObjects],
@"declined_permissions" : [token.declinedPermissions allObjects],
@"last_refresh" : [@(lastRefreshDate) stringValue],
@"graph_domain" : @"facebook",
};
}
}
return nil;
}
@end

View File

@@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: 5cafb2af7ca9641f58022a816236d1ad
timeCreated: 1435010266
licenseType: Pro
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Android:
enabled: 0
settings:
CPU: AnyCPU
Any:
enabled: 0
settings: {}
Editor:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
Linux:
enabled: 0
settings:
CPU: x86
Linux64:
enabled: 0
settings:
CPU: x86_64
OSXIntel:
enabled: 0
settings:
CPU: AnyCPU
OSXIntel64:
enabled: 0
settings:
CPU: AnyCPU
SamsungTV:
enabled: 0
settings:
STV_MODEL: STANDARD_13
Win:
enabled: 0
settings:
CPU: AnyCPU
Win64:
enabled: 0
settings:
CPU: AnyCPU
iOS:
enabled: 1
settings:
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 55b93cda5090e4a77abee14146407660
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,80 @@
/**
* 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.
*/
import FBSDKCoreKit
import FBSDKGamingServicesKit
import Foundation
@objc
public protocol FBSDKShareTournamentDialogDelegate: AnyObject {
func didComplete(dialog: FBSDKShareTournamentDialog, tournament: FBSDKTournament)
func didFail(withError error: Error, dialog: FBSDKShareTournamentDialog)
func didCancel(dialog: FBSDKShareTournamentDialog)
}
/// An internal wrapper for sharing tournaments via dialog
@objcMembers
public final class FBSDKShareTournamentDialog: NSObject, ShareTournamentDialogDelegate {
weak var delegate: FBSDKShareTournamentDialogDelegate?
private var dialog: ShareTournamentDialog?
public init(delegate: FBSDKShareTournamentDialogDelegate) {
self.delegate = delegate
super.init()
dialog = ShareTournamentDialog(delegate: self)
}
public func show(score: Int, tournamentID: String) throws {
try dialog?.show(score: score, tournamentID: tournamentID)
}
public func show(
initialScore: Int,
title: String? = nil,
endTime: Date? = nil,
scoreType: Int,
sortOrder: Int,
payload: String? = nil
) throws {
let currentConfig = TournamentConfig(
title: title,
endTime: endTime,
scoreType: scoreType == 0 ? .numeric : .time,
sortOrder: sortOrder == 0 ? .higherIsBetter : .lowerIsBetter,
image: nil,
payload: payload
)
try dialog?.show(initialScore: initialScore, config: currentConfig)
}
// MARK: FBSDKShareTournamentDialogDelegate
public func didComplete(dialog: ShareTournamentDialog, tournament: Tournament) {
delegate?.didComplete(dialog: self, tournament: FBSDKTournament(tournament: tournament))
}
public func didFail(withError error: Error, dialog: ShareTournamentDialog) {
delegate?.didFail(withError: error, dialog: self)
}
public func didCancel(dialog: ShareTournamentDialog) {
delegate?.didCancel(dialog: self)
}
}

Some files were not shown because too many files have changed in this diff Show More