From 6d611a5754004daebe48c88067e03c107dca4b43 Mon Sep 17 00:00:00 2001 From: Sean Wiese Date: Fri, 11 Sep 2015 16:32:57 -0700 Subject: [PATCH] Facebook SDK For Unity 7.1.0 --- .gitignore | 69 ++ CONTRIBUTING.mdown | 15 + Facebook.Unity.Tests/Android/AndroidTest.cs | 70 ++ Facebook.Unity.Tests/Android/AppInvite.cs | 44 + Facebook.Unity.Tests/Android/AppLinks.cs | 135 +++ Facebook.Unity.Tests/Android/Login.cs | 141 ++++ .../Android/MockAndroidJavaClass.cs | 60 ++ Facebook.Unity.Tests/Android/ShareLink.cs | 53 ++ .../Facebook.Unity.Tests.csproj | 67 ++ Facebook.Unity.Tests/FacebookTestClass.cs | 58 ++ Facebook.Unity.Tests/Utilities.cs | 34 + Facebook.Unity/.gitignore | 18 + Facebook.Unity/Assets/Examples.meta | 5 + .../Assets/Examples/AppEvents.unity | 213 +++++ .../Assets/Examples/AppEvents.unity.meta | 8 + .../Assets/Examples/AppInvites.unity | 213 +++++ .../Assets/Examples/AppInvites.unity.meta | 8 + Facebook.Unity/Assets/Examples/AppLinks.unity | 213 +++++ .../Assets/Examples/AppLinks.unity.meta | 8 + .../Assets/Examples/AppRequests.unity | 213 +++++ .../Assets/Examples/AppRequests.unity.meta | 8 + .../Assets/Examples/DialogShare.unity | 213 +++++ .../Assets/Examples/DialogShare.unity.meta | 8 + .../Assets/Examples/GameGroups.unity | 218 +++++ .../Assets/Examples/GameGroups.unity.meta | 8 + .../Assets/Examples/GraphRequest.unity | 213 +++++ .../Assets/Examples/GraphRequest.unity.meta | 8 + Facebook.Unity/Assets/Examples/LogView.unity | 213 +++++ .../Assets/Examples/LogView.unity.meta | 8 + Facebook.Unity/Assets/Examples/MainMenu.unity | 213 +++++ .../Assets/Examples/MainMenu.unity.meta | 4 + Facebook.Unity/Assets/Examples/Pay.unity | 213 +++++ Facebook.Unity/Assets/Examples/Pay.unity.meta | 8 + Facebook.Unity/Assets/Examples/Scripts.meta | 5 + .../Assets/Examples/Scripts/ConsoleBase.cs | 241 ++++++ .../Examples/Scripts/ConsoleBase.cs.meta | 8 + .../Assets/Examples/Scripts/LogView.cs | 72 ++ .../Assets/Examples/Scripts/LogView.cs.meta | 12 + .../Assets/Examples/Scripts/MenuBase.cs | 178 ++++ .../Assets/Examples/Scripts/MenuBase.cs.meta | 12 + .../Assets/Examples/Scripts/SubMenus.meta | 9 + .../Examples/Scripts/SubMenus/AppEvents.cs | 47 ++ .../Scripts/SubMenus/AppEvents.cs.meta | 12 + .../Examples/Scripts/SubMenus/AppInvites.cs | 56 ++ .../Scripts/SubMenus/AppInvites.cs.meta | 12 + .../Examples/Scripts/SubMenus/AppLinks.cs | 41 + .../Scripts/SubMenus/AppLinks.cs.meta | 12 + .../Examples/Scripts/SubMenus/AppRequests.cs | 144 ++++ .../Scripts/SubMenus/AppRequests.cs.meta | 12 + .../Examples/Scripts/SubMenus/DialogShare.cs | 121 +++ .../Scripts/SubMenus/DialogShare.cs.meta | 12 + .../Examples/Scripts/SubMenus/GameGroups.cs | 162 ++++ .../Scripts/SubMenus/GameGroups.cs.meta | 12 + .../Examples/Scripts/SubMenus/GraphRequest.cs | 75 ++ .../Scripts/SubMenus/GraphRequest.cs.meta | 12 + .../Examples/Scripts/SubMenus/MainMenu.cs | 154 ++++ .../Scripts/SubMenus/MainMenu.cs.meta | 12 + .../Assets/Examples/Scripts/SubMenus/Pay.cs | 47 ++ .../Examples/Scripts/SubMenus/Pay.cs.meta | 12 + Facebook.Unity/Assets/Examples/Textures.meta | 5 + .../Assets/Examples/Textures/White.psd | Bin 0 -> 23542 bytes .../Assets/Examples/Textures/White.psd.meta | 46 ++ Facebook.Unity/Assets/Facebook.meta | 5 + Facebook.Unity/Assets/Facebook/Debug.meta | 9 + Facebook.Unity/Assets/Facebook/Editor.meta | 5 + .../Assets/Facebook/Editor/FacebookBuild.cs | 85 ++ .../Facebook/Editor/FacebookBuild.cs.meta | 12 + .../Facebook/Editor/FacebookPostprocess.cs | 92 +++ .../Editor/FacebookPostprocess.cs.meta | 8 + .../Facebook/Editor/FacebookSettingsEditor.cs | 297 +++++++ .../Editor/FacebookSettingsEditor.cs.meta | 8 + .../Assets/Facebook/Editor/Utility.cs | 58 ++ .../Assets/Facebook/Editor/Utility.cs.meta | 12 + .../Assets/Facebook/Editor/android.meta | 5 + .../Editor/android/FacebookAndroidUtil.cs | 176 ++++ .../android/FacebookAndroidUtil.cs.meta | 8 + .../Facebook/Editor/android/ManifestMod.cs | 354 ++++++++ .../Editor/android/ManifestMod.cs.meta | 8 + .../Assets/Facebook/Editor/iOS.meta | 5 + .../Facebook/Editor/iOS/FBSDK+Internal.h | 35 + .../Facebook/Editor/iOS/FBSDK+Internal.h.meta | 59 ++ .../Facebook/Editor/iOS/FBUnityInterface.h | 45 + .../Editor/iOS/FBUnityInterface.h.meta | 57 ++ .../Facebook/Editor/iOS/FBUnityInterface.mm | 588 +++++++++++++ .../Editor/iOS/FBUnityInterface.mm.meta | 57 ++ .../Facebook/Editor/iOS/FBUnitySDKDelegate.h | 48 ++ .../Editor/iOS/FBUnitySDKDelegate.h.meta | 59 ++ .../Facebook/Editor/iOS/FBUnitySDKDelegate.m | 171 ++++ .../Editor/iOS/FBUnitySDKDelegate.m.meta | 59 ++ .../Facebook/Editor/iOS/FBUnityUtility.h | 33 + .../Facebook/Editor/iOS/FBUnityUtility.h.meta | 59 ++ .../Facebook/Editor/iOS/FBUnityUtility.mm | 175 ++++ .../Editor/iOS/FBUnityUtility.mm.meta | 59 ++ .../Facebook/Editor/iOS/FacebookSDK.meta | 7 + .../Assets/Facebook/Editor/iOS/FixupFiles.cs | 143 ++++ .../Facebook/Editor/iOS/FixupFiles.cs.meta | 8 + .../Assets/Facebook/Editor/iOS/PListDict.cs | 165 ++++ .../Facebook/Editor/iOS/PListDict.cs.meta | 8 + .../Assets/Facebook/Editor/iOS/PListParser.cs | 243 ++++++ .../Facebook/Editor/iOS/PListParser.cs.meta | 8 + .../Assets/Facebook/Editor/iOS/fixup.projmods | 24 + .../Facebook/Editor/iOS/fixup.projmods.meta | 4 + Facebook.Unity/Assets/Facebook/Prefabs.meta | 9 + Facebook.Unity/Assets/Facebook/Resources.meta | 9 + Facebook.Unity/Assets/Facebook/Scripts.meta | 5 + .../Assets/Facebook/Scripts/AccessToken.cs | 114 +++ .../Facebook/Scripts/AccessToken.cs.meta | 12 + .../Assets/Facebook/Scripts/AppEventName.cs | 43 + .../Facebook/Scripts/AppEventName.cs.meta | 12 + .../Facebook/Scripts/AppEventParameterName.cs | 40 + .../Scripts/AppEventParameterName.cs.meta | 12 + .../Facebook/Scripts/CallbackManager.cs | 93 +++ .../Facebook/Scripts/CallbackManager.cs.meta | 12 + .../Assets/Facebook/Scripts/Canvas.meta | 9 + .../Facebook/Scripts/Canvas/CanvasFacebook.cs | 493 +++++++++++ .../Scripts/Canvas/CanvasFacebook.cs.meta | 12 + .../Canvas/CanvasFacebookGameObject.cs | 65 ++ .../Canvas/CanvasFacebookGameObject.cs.meta | 12 + .../Scripts/Canvas/CanvasFacebookLoader.cs | 42 + .../Canvas/CanvasFacebookLoader.cs.meta | 12 + .../Scripts/Canvas/ICanvasFacebook.cs | 38 + .../Scripts/Canvas/ICanvasFacebook.cs.meta | 12 + .../Canvas/ICanvasFacebookCallbackHandler.cs | 38 + .../ICanvasFacebookCallbackHandler.cs.meta | 12 + .../Canvas/ICanvasFacebookImplementation.cs | 28 + .../ICanvasFacebookImplementation.cs.meta | 12 + .../Facebook/Scripts/Canvas/JsBridge.cs | 86 ++ .../Facebook/Scripts/Canvas/JsBridge.cs.meta | 12 + .../Facebook/Scripts/Canvas/Resources.meta | 9 + .../Canvas/Resources/JSSDKBindings.txt | 185 +++++ .../Canvas/Resources/JSSDKBindings.txt.meta | 8 + .../Facebook/Scripts/ComponentFactory.cs | 74 ++ .../Facebook/Scripts/ComponentFactory.cs.meta | 12 + .../Assets/Facebook/Scripts/Constants.cs | 87 ++ .../Assets/Facebook/Scripts/Constants.cs.meta | 12 + Facebook.Unity/Assets/Facebook/Scripts/FB.cs | 776 ++++++++++++++++++ .../Assets/Facebook/Scripts/FB.cs.meta | 8 + .../Assets/Facebook/Scripts/FacebookBase.cs | 280 +++++++ .../Facebook/Scripts/FacebookBase.cs.meta | 12 + .../Facebook/Scripts/FacebookGameObject.cs | 95 +++ .../Scripts/FacebookGameObject.cs.meta | 12 + .../Facebook/Scripts/FacebookSdkVersion.cs | 38 + .../Scripts/FacebookSdkVersion.cs.meta | 12 + .../Facebook/Scripts/FacebookSettings.cs | 398 +++++++++ .../Facebook/Scripts/FacebookSettings.cs.meta | 12 + .../Assets/Facebook/Scripts/IFacebook.cs | 133 +++ .../Assets/Facebook/Scripts/IFacebook.cs.meta | 12 + .../Scripts/IFacebookCallbackHandler.cs | 41 + .../Scripts/IFacebookCallbackHandler.cs.meta | 12 + .../Scripts/IFacebookImplementation.cs | 26 + .../Scripts/IFacebookImplementation.cs.meta | 12 + .../Facebook/Scripts/MethodArguments.cs | 119 +++ .../Facebook/Scripts/MethodArguments.cs.meta | 12 + .../Assets/Facebook/Scripts/MethodCall.cs | 45 + .../Facebook/Scripts/MethodCall.cs.meta | 12 + .../Assets/Facebook/Scripts/Mobile.meta | 9 + .../Facebook/Scripts/Mobile/Android.meta | 9 + .../Scripts/Mobile/Android/AndroidFacebook.cs | 355 ++++++++ .../Mobile/Android/AndroidFacebook.cs.meta | 12 + .../Android/AndroidFacebookGameObject.cs | 35 + .../Android/AndroidFacebookGameObject.cs.meta | 12 + .../Mobile/Android/AndroidFacebookLoader.cs | 42 + .../Android/AndroidFacebookLoader.cs.meta | 12 + .../Scripts/Mobile/Android/FBJavaClass.cs | 65 ++ .../Mobile/Android/FBJavaClass.cs.meta | 12 + .../Mobile/Android/IAndroidJavaClass.cs | 29 + .../Mobile/Android/IAndroidJavaClass.cs.meta | 12 + .../Scripts/Mobile/IMobileFacebook.cs | 37 + .../Scripts/Mobile/IMobileFacebook.cs.meta | 12 + .../Mobile/IMobileFacebookCallbackHandler.cs | 29 + .../IMobileFacebookCallbackHandler.cs.meta | 12 + .../Mobile/IMobileFacebookImplementation.cs | 26 + .../IMobileFacebookImplementation.cs.meta | 12 + .../Assets/Facebook/Scripts/Mobile/IOS.meta | 9 + .../Scripts/Mobile/IOS/IOSFacebook.cs | 601 ++++++++++++++ .../Scripts/Mobile/IOS/IOSFacebook.cs.meta | 12 + .../Mobile/IOS/IOSFacebookGameObject.cs | 26 + .../Mobile/IOS/IOSFacebookGameObject.cs.meta | 12 + .../Scripts/Mobile/IOS/IOSFacebookLoader.cs | 42 + .../Mobile/IOS/IOSFacebookLoader.cs.meta | 12 + .../Facebook/Scripts/Mobile/MobileFacebook.cs | 151 ++++ .../Scripts/Mobile/MobileFacebook.cs.meta | 12 + .../Mobile/MobileFacebookGameObject.cs | 45 + .../Mobile/MobileFacebookGameObject.cs.meta | 12 + .../Facebook/Scripts/NativeDialogModes.cs | 48 ++ .../Scripts/NativeDialogModes.cs.meta | 12 + .../Assets/Facebook/Scripts/OGActionType.cs | 29 + .../Facebook/Scripts/OGActionType.cs.meta | 8 + .../Facebook/Scripts/PlatformAndroid.meta | 9 + .../Facebook/Scripts/PlatformEditor.meta | 9 + .../Scripts/PlatformEditor/EditorFacebook.cs | 313 +++++++ .../PlatformEditor/EditorFacebook.cs.meta | 8 + .../EditorFacebookGameObject.cs | 26 + .../EditorFacebookGameObject.cs.meta | 12 + .../PlatformEditor/EditorFacebookLoader.cs | 37 + .../EditorFacebookLoader.cs.meta | 8 + .../EditorFacebookMockDialog.cs | 125 +++ .../EditorFacebookMockDialog.cs.meta | 12 + .../Scripts/PlatformEditor/MockDialogs.meta | 9 + .../MockDialogs/EmptyMockDialog.cs | 67 ++ .../MockDialogs/EmptyMockDialog.cs.meta | 12 + .../MockDialogs/MockLoginDialog.cs | 88 ++ .../MockDialogs/MockLoginDialog.cs.meta | 12 + .../Assets/Facebook/Scripts/PlatformIOS.meta | 9 + .../Assets/Facebook/Scripts/Properties.meta | 9 + .../Scripts/Properties/AssemblyInfo.cs | 23 + .../Scripts/Properties/AssemblyInfo.cs.meta | 12 + .../Assets/Facebook/Scripts/Results.meta | 9 + .../Scripts/Results/AppInviteResult.cs | 29 + .../Scripts/Results/AppInviteResult.cs.meta | 12 + .../Facebook/Scripts/Results/AppLinkResult.cs | 66 ++ .../Scripts/Results/AppLinkResult.cs.meta | 12 + .../Scripts/Results/AppReqeustResult.cs | 51 ++ .../Scripts/Results/AppReqeustResult.cs.meta | 12 + .../Facebook/Scripts/Results/GraphResult.cs | 60 ++ .../Scripts/Results/GraphResult.cs.meta | 12 + .../Scripts/Results/GroupCreateResult.cs | 41 + .../Scripts/Results/GroupCreateResult.cs.meta | 12 + .../Scripts/Results/GroupJoinResult.cs | 29 + .../Scripts/Results/GroupJoinResult.cs.meta | 12 + .../Scripts/Results/IAppInviteResult.cs | 29 + .../Scripts/Results/IAppInviteResult.cs.meta | 12 + .../Scripts/Results/IAppLinkResult.cs | 61 ++ .../Scripts/Results/IAppLinkResult.cs.meta | 12 + .../Scripts/Results/IAppRequestResult.cs | 43 + .../Scripts/Results/IAppRequestResult.cs.meta | 12 + .../Facebook/Scripts/Results/IGraphResult.cs | 37 + .../Scripts/Results/IGraphResult.cs.meta | 12 + .../Scripts/Results/IGroupCreateResult.cs | 34 + .../Results/IGroupCreateResult.cs.meta | 12 + .../Scripts/Results/IGroupJoinResult.cs | 29 + .../Scripts/Results/IGroupJoinResult.cs.meta | 12 + .../Scripts/Results/IInternalResult.cs | 31 + .../Scripts/Results/IInternalResult.cs.meta | 12 + .../Facebook/Scripts/Results/ILoginResult.cs | 34 + .../Scripts/Results/ILoginResult.cs.meta | 12 + .../Facebook/Scripts/Results/IPayResult.cs | 29 + .../Scripts/Results/IPayResult.cs.meta | 12 + .../Facebook/Scripts/Results/IResult.cs | 55 ++ .../Facebook/Scripts/Results/IResult.cs.meta | 12 + .../Facebook/Scripts/Results/IShareResult.cs | 34 + .../Scripts/Results/IShareResult.cs.meta | 12 + .../Facebook/Scripts/Results/LoginResult.cs | 154 ++++ .../Scripts/Results/LoginResult.cs.meta | 12 + .../Facebook/Scripts/Results/PayResult.cs | 29 + .../Scripts/Results/PayResult.cs.meta | 12 + .../Facebook/Scripts/Results/ResultBase.cs | 148 ++++ .../Scripts/Results/ResultBase.cs.meta | 12 + .../Facebook/Scripts/Results/ShareResult.cs | 42 + .../Scripts/Results/ShareResult.cs.meta | 12 + .../Assets/Facebook/Scripts/Utils.meta | 9 + .../Scripts/Utils/AsyncRequestString.cs | 163 ++++ .../Scripts/Utils/AsyncRequestString.cs.meta | 8 + .../Facebook/Scripts/Utils/FacebookLogger.cs | 225 +++++ .../Scripts/Utils/FacebookLogger.cs.meta | 12 + .../Facebook/Scripts/Utils/HttpMethod.cs | 43 + .../Facebook/Scripts/Utils/HttpMethod.cs.meta | 8 + .../Facebook/Scripts/Utils/IFacebookLogger.cs | 33 + .../Scripts/Utils/IFacebookLogger.cs.meta | 12 + .../Assets/Facebook/Scripts/Utils/MiniJson.cs | 624 ++++++++++++++ .../Facebook/Scripts/Utils/MiniJson.cs.meta | 8 + .../Facebook/Scripts/Utils/Utilities.cs | 89 ++ .../Facebook/Scripts/Utils/Utilities.cs.meta | 12 + Facebook.Unity/Assets/FacebookMeta.meta | 5 + Facebook.Unity/Assets/FacebookTest.meta | 5 + Facebook.Unity/Assets/Plugins.meta | 5 + Facebook.Unity/Assets/Plugins/Android.meta | 9 + Facebook.Unity/Assets/Plugins/iOS.meta | 9 + Facebook.Unity/Assets/Resources.meta | 9 + .../ProjectSettings/AudioManager.asset | 11 + .../ProjectSettings/DynamicsManager.asset | 15 + .../ProjectSettings/EditorBuildSettings.asset | 27 + .../ProjectSettings/EditorSettings.asset | 10 + .../ProjectSettings/GraphicsSettings.asset | 29 + .../ProjectSettings/InputManager.asset | 246 ++++++ .../ProjectSettings/NavMeshAreas.asset | 133 +++ .../ProjectSettings/NavMeshLayers.asset | 133 +++ .../ProjectSettings/NetworkManager.asset | 8 + .../ProjectSettings/Physics2DSettings.asset | 24 + .../ProjectSettings/ProjectSettings.asset | 463 +++++++++++ .../ProjectSettings/QualitySettings.asset | 147 ++++ .../ProjectSettings/TagManager.asset | 38 + .../ProjectSettings/TimeManager.asset | 8 + .../ProjectSettings/UnityAdsSettings.asset | 11 + .../UnityAnalyticsManager.asset | 10 + LICENSE.txt | 17 + README.mdown | 50 ++ facebook-android-wrapper/AndroidManifest.xml | 25 + facebook-android-wrapper/build.gradle | 69 ++ facebook-android-wrapper/gradle.properties | 18 + .../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 52266 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 + facebook-android-wrapper/gradlew | 164 ++++ facebook-android-wrapper/gradlew.bat | 90 ++ facebook-android-wrapper/proguard-project.txt | 20 + facebook-android-wrapper/project.properties | 13 + .../unity/AppInviteDialogActivity.java | 74 ++ .../src/com/facebook/unity/BaseActivity.java | 45 + .../src/com/facebook/unity/Constants.java | 25 + .../src/com/facebook/unity/FB.java | 385 +++++++++ .../src/com/facebook/unity/FBDialogUtils.java | 101 +++ .../src/com/facebook/unity/FBLogin.java | 126 +++ .../unity/FBUnityAppLinkActivity.java | 25 + .../unity/FBUnityAppLinkBaseActivity.java | 55 ++ .../unity/FBUnityCreateGameGroupActivity.java | 97 +++ .../unity/FBUnityDeepLinkingActivity.java | 24 + .../unity/FBUnityDialogsActivity.java | 97 +++ .../unity/FBUnityGameRequestActivity.java | 119 +++ .../unity/FBUnityJoinGameGroupActivity.java | 68 ++ .../facebook/unity/FBUnityLoginActivity.java | 57 ++ .../src/com/facebook/unity/UnityCallable.java | 29 + .../src/com/facebook/unity/UnityMessage.java | 77 ++ .../src/com/facebook/unity/UnityParams.java | 132 +++ .../com/facebook/unity/UnityReflection.java | 66 ++ scripts/build.properties | 28 + scripts/build.sh | 26 + scripts/common.sh | 86 ++ scripts/setup_android_unity_plugin.sh | 115 +++ scripts/setup_ios_unity_plugin.sh | 63 ++ 319 files changed, 20364 insertions(+) create mode 100644 .gitignore create mode 100644 CONTRIBUTING.mdown create mode 100644 Facebook.Unity.Tests/Android/AndroidTest.cs create mode 100644 Facebook.Unity.Tests/Android/AppInvite.cs create mode 100644 Facebook.Unity.Tests/Android/AppLinks.cs create mode 100644 Facebook.Unity.Tests/Android/Login.cs create mode 100644 Facebook.Unity.Tests/Android/MockAndroidJavaClass.cs create mode 100644 Facebook.Unity.Tests/Android/ShareLink.cs create mode 100644 Facebook.Unity.Tests/Facebook.Unity.Tests.csproj create mode 100644 Facebook.Unity.Tests/FacebookTestClass.cs create mode 100644 Facebook.Unity.Tests/Utilities.cs create mode 100644 Facebook.Unity/.gitignore create mode 100644 Facebook.Unity/Assets/Examples.meta create mode 100644 Facebook.Unity/Assets/Examples/AppEvents.unity create mode 100644 Facebook.Unity/Assets/Examples/AppEvents.unity.meta create mode 100644 Facebook.Unity/Assets/Examples/AppInvites.unity create mode 100644 Facebook.Unity/Assets/Examples/AppInvites.unity.meta create mode 100644 Facebook.Unity/Assets/Examples/AppLinks.unity create mode 100644 Facebook.Unity/Assets/Examples/AppLinks.unity.meta create mode 100644 Facebook.Unity/Assets/Examples/AppRequests.unity create mode 100644 Facebook.Unity/Assets/Examples/AppRequests.unity.meta create mode 100644 Facebook.Unity/Assets/Examples/DialogShare.unity create mode 100644 Facebook.Unity/Assets/Examples/DialogShare.unity.meta create mode 100644 Facebook.Unity/Assets/Examples/GameGroups.unity create mode 100644 Facebook.Unity/Assets/Examples/GameGroups.unity.meta create mode 100644 Facebook.Unity/Assets/Examples/GraphRequest.unity create mode 100644 Facebook.Unity/Assets/Examples/GraphRequest.unity.meta create mode 100644 Facebook.Unity/Assets/Examples/LogView.unity create mode 100644 Facebook.Unity/Assets/Examples/LogView.unity.meta create mode 100644 Facebook.Unity/Assets/Examples/MainMenu.unity create mode 100644 Facebook.Unity/Assets/Examples/MainMenu.unity.meta create mode 100644 Facebook.Unity/Assets/Examples/Pay.unity create mode 100644 Facebook.Unity/Assets/Examples/Pay.unity.meta create mode 100644 Facebook.Unity/Assets/Examples/Scripts.meta create mode 100644 Facebook.Unity/Assets/Examples/Scripts/ConsoleBase.cs create mode 100644 Facebook.Unity/Assets/Examples/Scripts/ConsoleBase.cs.meta create mode 100644 Facebook.Unity/Assets/Examples/Scripts/LogView.cs create mode 100644 Facebook.Unity/Assets/Examples/Scripts/LogView.cs.meta create mode 100644 Facebook.Unity/Assets/Examples/Scripts/MenuBase.cs create mode 100644 Facebook.Unity/Assets/Examples/Scripts/MenuBase.cs.meta create mode 100644 Facebook.Unity/Assets/Examples/Scripts/SubMenus.meta create mode 100644 Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppEvents.cs create mode 100644 Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppEvents.cs.meta create mode 100644 Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppInvites.cs create mode 100644 Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppInvites.cs.meta create mode 100644 Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppLinks.cs create mode 100644 Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppLinks.cs.meta create mode 100644 Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppRequests.cs create mode 100644 Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppRequests.cs.meta create mode 100644 Facebook.Unity/Assets/Examples/Scripts/SubMenus/DialogShare.cs create mode 100644 Facebook.Unity/Assets/Examples/Scripts/SubMenus/DialogShare.cs.meta create mode 100644 Facebook.Unity/Assets/Examples/Scripts/SubMenus/GameGroups.cs create mode 100644 Facebook.Unity/Assets/Examples/Scripts/SubMenus/GameGroups.cs.meta create mode 100644 Facebook.Unity/Assets/Examples/Scripts/SubMenus/GraphRequest.cs create mode 100644 Facebook.Unity/Assets/Examples/Scripts/SubMenus/GraphRequest.cs.meta create mode 100644 Facebook.Unity/Assets/Examples/Scripts/SubMenus/MainMenu.cs create mode 100644 Facebook.Unity/Assets/Examples/Scripts/SubMenus/MainMenu.cs.meta create mode 100644 Facebook.Unity/Assets/Examples/Scripts/SubMenus/Pay.cs create mode 100644 Facebook.Unity/Assets/Examples/Scripts/SubMenus/Pay.cs.meta create mode 100644 Facebook.Unity/Assets/Examples/Textures.meta create mode 100644 Facebook.Unity/Assets/Examples/Textures/White.psd create mode 100644 Facebook.Unity/Assets/Examples/Textures/White.psd.meta create mode 100644 Facebook.Unity/Assets/Facebook.meta create mode 100644 Facebook.Unity/Assets/Facebook/Debug.meta create mode 100644 Facebook.Unity/Assets/Facebook/Editor.meta create mode 100644 Facebook.Unity/Assets/Facebook/Editor/FacebookBuild.cs create mode 100644 Facebook.Unity/Assets/Facebook/Editor/FacebookBuild.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Editor/FacebookPostprocess.cs create mode 100644 Facebook.Unity/Assets/Facebook/Editor/FacebookPostprocess.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Editor/FacebookSettingsEditor.cs create mode 100644 Facebook.Unity/Assets/Facebook/Editor/FacebookSettingsEditor.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Editor/Utility.cs create mode 100644 Facebook.Unity/Assets/Facebook/Editor/Utility.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Editor/android.meta create mode 100644 Facebook.Unity/Assets/Facebook/Editor/android/FacebookAndroidUtil.cs create mode 100644 Facebook.Unity/Assets/Facebook/Editor/android/FacebookAndroidUtil.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Editor/android/ManifestMod.cs create mode 100644 Facebook.Unity/Assets/Facebook/Editor/android/ManifestMod.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS.meta create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/FBSDK+Internal.h create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/FBSDK+Internal.h.meta create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityInterface.h create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityInterface.h.meta create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityInterface.mm create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityInterface.mm.meta create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnitySDKDelegate.h create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnitySDKDelegate.h.meta create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnitySDKDelegate.m create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnitySDKDelegate.m.meta create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityUtility.h create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityUtility.h.meta create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityUtility.mm create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityUtility.mm.meta create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/FacebookSDK.meta create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/FixupFiles.cs create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/FixupFiles.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/PListDict.cs create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/PListDict.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/PListParser.cs create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/PListParser.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/fixup.projmods create mode 100644 Facebook.Unity/Assets/Facebook/Editor/iOS/fixup.projmods.meta create mode 100644 Facebook.Unity/Assets/Facebook/Prefabs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Resources.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/AccessToken.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/AccessToken.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/AppEventName.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/AppEventName.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/AppEventParameterName.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/AppEventParameterName.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/CallbackManager.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/CallbackManager.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Canvas.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebook.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebook.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebookGameObject.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebookGameObject.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebookLoader.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebookLoader.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebook.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebook.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebookCallbackHandler.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebookCallbackHandler.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebookImplementation.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebookImplementation.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Canvas/JsBridge.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Canvas/JsBridge.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Canvas/Resources.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Canvas/Resources/JSSDKBindings.txt create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Canvas/Resources/JSSDKBindings.txt.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/ComponentFactory.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/ComponentFactory.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Constants.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Constants.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/FB.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/FB.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/FacebookBase.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/FacebookBase.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/FacebookGameObject.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/FacebookGameObject.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/FacebookSdkVersion.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/FacebookSdkVersion.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/FacebookSettings.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/FacebookSettings.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/IFacebook.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/IFacebook.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/IFacebookCallbackHandler.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/IFacebookCallbackHandler.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/IFacebookImplementation.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/IFacebookImplementation.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/MethodArguments.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/MethodArguments.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/MethodCall.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/MethodCall.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebook.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebook.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebookGameObject.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebookGameObject.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebookLoader.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebookLoader.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/FBJavaClass.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/FBJavaClass.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/IAndroidJavaClass.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/IAndroidJavaClass.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebook.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebook.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebookCallbackHandler.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebookCallbackHandler.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebookImplementation.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebookImplementation.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebook.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebook.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebookGameObject.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebookGameObject.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebookLoader.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebookLoader.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/MobileFacebook.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/MobileFacebook.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/MobileFacebookGameObject.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Mobile/MobileFacebookGameObject.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/NativeDialogModes.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/NativeDialogModes.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/OGActionType.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/OGActionType.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/PlatformAndroid.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebook.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebook.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookGameObject.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookGameObject.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookLoader.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookLoader.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookMockDialog.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookMockDialog.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/MockDialogs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/MockDialogs/EmptyMockDialog.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/MockDialogs/EmptyMockDialog.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/MockDialogs/MockLoginDialog.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/MockDialogs/MockLoginDialog.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/PlatformIOS.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Properties.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Properties/AssemblyInfo.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Properties/AssemblyInfo.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/AppInviteResult.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/AppInviteResult.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/AppLinkResult.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/AppLinkResult.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/AppReqeustResult.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/AppReqeustResult.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/GraphResult.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/GraphResult.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/GroupCreateResult.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/GroupCreateResult.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/GroupJoinResult.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/GroupJoinResult.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/IAppInviteResult.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/IAppInviteResult.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/IAppLinkResult.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/IAppLinkResult.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/IAppRequestResult.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/IAppRequestResult.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/IGraphResult.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/IGraphResult.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/IGroupCreateResult.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/IGroupCreateResult.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/IGroupJoinResult.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/IGroupJoinResult.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/IInternalResult.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/IInternalResult.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/ILoginResult.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/ILoginResult.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/IPayResult.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/IPayResult.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/IResult.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/IResult.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/IShareResult.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/IShareResult.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/LoginResult.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/LoginResult.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/PayResult.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/PayResult.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/ResultBase.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/ResultBase.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/ShareResult.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Results/ShareResult.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Utils.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Utils/AsyncRequestString.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Utils/AsyncRequestString.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Utils/FacebookLogger.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Utils/FacebookLogger.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Utils/HttpMethod.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Utils/HttpMethod.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Utils/IFacebookLogger.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Utils/IFacebookLogger.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Utils/MiniJson.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Utils/MiniJson.cs.meta create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Utils/Utilities.cs create mode 100644 Facebook.Unity/Assets/Facebook/Scripts/Utils/Utilities.cs.meta create mode 100644 Facebook.Unity/Assets/FacebookMeta.meta create mode 100644 Facebook.Unity/Assets/FacebookTest.meta create mode 100644 Facebook.Unity/Assets/Plugins.meta create mode 100644 Facebook.Unity/Assets/Plugins/Android.meta create mode 100644 Facebook.Unity/Assets/Plugins/iOS.meta create mode 100644 Facebook.Unity/Assets/Resources.meta create mode 100644 Facebook.Unity/ProjectSettings/AudioManager.asset create mode 100644 Facebook.Unity/ProjectSettings/DynamicsManager.asset create mode 100644 Facebook.Unity/ProjectSettings/EditorBuildSettings.asset create mode 100644 Facebook.Unity/ProjectSettings/EditorSettings.asset create mode 100644 Facebook.Unity/ProjectSettings/GraphicsSettings.asset create mode 100644 Facebook.Unity/ProjectSettings/InputManager.asset create mode 100644 Facebook.Unity/ProjectSettings/NavMeshAreas.asset create mode 100644 Facebook.Unity/ProjectSettings/NavMeshLayers.asset create mode 100644 Facebook.Unity/ProjectSettings/NetworkManager.asset create mode 100644 Facebook.Unity/ProjectSettings/Physics2DSettings.asset create mode 100644 Facebook.Unity/ProjectSettings/ProjectSettings.asset create mode 100644 Facebook.Unity/ProjectSettings/QualitySettings.asset create mode 100644 Facebook.Unity/ProjectSettings/TagManager.asset create mode 100644 Facebook.Unity/ProjectSettings/TimeManager.asset create mode 100644 Facebook.Unity/ProjectSettings/UnityAdsSettings.asset create mode 100644 Facebook.Unity/ProjectSettings/UnityAnalyticsManager.asset create mode 100644 LICENSE.txt create mode 100644 README.mdown create mode 100644 facebook-android-wrapper/AndroidManifest.xml create mode 100644 facebook-android-wrapper/build.gradle create mode 100644 facebook-android-wrapper/gradle.properties create mode 100644 facebook-android-wrapper/gradle/wrapper/gradle-wrapper.jar create mode 100644 facebook-android-wrapper/gradle/wrapper/gradle-wrapper.properties create mode 100755 facebook-android-wrapper/gradlew create mode 100644 facebook-android-wrapper/gradlew.bat create mode 100644 facebook-android-wrapper/proguard-project.txt create mode 100644 facebook-android-wrapper/project.properties create mode 100644 facebook-android-wrapper/src/com/facebook/unity/AppInviteDialogActivity.java create mode 100644 facebook-android-wrapper/src/com/facebook/unity/BaseActivity.java create mode 100644 facebook-android-wrapper/src/com/facebook/unity/Constants.java create mode 100644 facebook-android-wrapper/src/com/facebook/unity/FB.java create mode 100644 facebook-android-wrapper/src/com/facebook/unity/FBDialogUtils.java create mode 100644 facebook-android-wrapper/src/com/facebook/unity/FBLogin.java create mode 100644 facebook-android-wrapper/src/com/facebook/unity/FBUnityAppLinkActivity.java create mode 100644 facebook-android-wrapper/src/com/facebook/unity/FBUnityAppLinkBaseActivity.java create mode 100644 facebook-android-wrapper/src/com/facebook/unity/FBUnityCreateGameGroupActivity.java create mode 100644 facebook-android-wrapper/src/com/facebook/unity/FBUnityDeepLinkingActivity.java create mode 100644 facebook-android-wrapper/src/com/facebook/unity/FBUnityDialogsActivity.java create mode 100644 facebook-android-wrapper/src/com/facebook/unity/FBUnityGameRequestActivity.java create mode 100644 facebook-android-wrapper/src/com/facebook/unity/FBUnityJoinGameGroupActivity.java create mode 100644 facebook-android-wrapper/src/com/facebook/unity/FBUnityLoginActivity.java create mode 100644 facebook-android-wrapper/src/com/facebook/unity/UnityCallable.java create mode 100644 facebook-android-wrapper/src/com/facebook/unity/UnityMessage.java create mode 100644 facebook-android-wrapper/src/com/facebook/unity/UnityParams.java create mode 100644 facebook-android-wrapper/src/com/facebook/unity/UnityReflection.java create mode 100644 scripts/build.properties create mode 100755 scripts/build.sh create mode 100755 scripts/common.sh create mode 100755 scripts/setup_android_unity_plugin.sh create mode 100755 scripts/setup_ios_unity_plugin.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..26ec5bea0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,69 @@ +# built application files +*.apk +*.ap_ + +# files for the dex VM +*.dex + +# Java class files +*.class + +# generated files +bin/ +gen/ + +# Local configuration file (sdk path, etc) +local.properties +local.gradle + +# Proguard folder generated by Eclipse +proguard/ + +# Intellij project files +*.iml +*.ipr +*.iws +.idea/ + +# Gradle +.gradle +build + +# vim temp files +*.swp + +# Arc generated +.phutil_module_cache + +# Unity3D generated meta files +*.pidb.meta + +# Unity3D Generated File On Crash Reports +sysinfo.txt + +# Unity project version File +ProjectVersion.txt + +# Export Folder For SDK Package +/TempGenStaticObjects/ +/out/ + +# MD unit test results +test-results/ +unit_test_results.txt + +# Ignore Plugin Folders which are build by build +/Facebook.Unity/Assets/Plugins/Android/ +/Facebook.Unity/Assets/Plugins/iOS/ + +# Ignore Current Facebook Settings +FacebookSettings.asset* + +# Ignore androdi wrapper lib created by build scripts +/facebook-android-wrapper/libs/ + +# MD Plugins +*.StyleCop +*.StyleCop.meta +StyleCop.Cache +StyleCop.Cache.meta diff --git a/CONTRIBUTING.mdown b/CONTRIBUTING.mdown new file mode 100644 index 000000000..ec5ea367e --- /dev/null +++ b/CONTRIBUTING.mdown @@ -0,0 +1,15 @@ +Facebook welcomes contributions to our SDKs. + +All contributors must sign a CLA (contributor license agreement) here: + + https://developers.facebook.com/opensource/cla + +To contribute on behalf of your employer, sign the company CLA +To contribute on behalf of yourself, sign the individual CLA + +All contributions: + +1/ MUST be be licensed using the Apache License, Version 2.0 +2/ authors MAY retain copyright by adding their copyright notice to the appropriate flies + +More information on the Apache License can be found here: http://www.apache.org/foundation/license-faq.html diff --git a/Facebook.Unity.Tests/Android/AndroidTest.cs b/Facebook.Unity.Tests/Android/AndroidTest.cs new file mode 100644 index 000000000..6c10e06e6 --- /dev/null +++ b/Facebook.Unity.Tests/Android/AndroidTest.cs @@ -0,0 +1,70 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Tests +{ + using System; + using System.Collections.Generic; + using Facebook.Unity.Mobile.Android; + using NUnit.Framework; + + internal class AndroidTest where T : IResult + { + private readonly MockAndroidJavaClass mock; + private readonly CallbackManager callbackManager; + + public AndroidTest() + { + this.mock = new MockAndroidJavaClass(); + this.callbackManager = new CallbackManager(); + this.AndroidFacebook = new AndroidFacebook(this.mock, this.callbackManager); + } + + public delegate void ResultValidator(T result); + + public ResultValidator CallbackResultValidator { get; set; } + + public IDictionary ExpectedResult { private get; set; } + + public AndroidFacebook AndroidFacebook { get; private set; } + + public void Run(Action> method, MockAndroidJavaClass.OnResult handler) + { + string expectedResultStr = MiniJSON.Json.Serialize(this.ExpectedResult); + this.mock.Callback = handler; + this.mock.Result = expectedResultStr; + bool callbackCalled = false; + + FacebookDelegate callback = delegate(T result) + { + if (this.CallbackResultValidator != null) + { + this.CallbackResultValidator(result); + } + + Assert.AreEqual(expectedResultStr, result.RawResult); + callbackCalled = true; + }; + + method(callback); + Assert.IsTrue(callbackCalled); + } + } +} diff --git a/Facebook.Unity.Tests/Android/AppInvite.cs b/Facebook.Unity.Tests/Android/AppInvite.cs new file mode 100644 index 000000000..f9a47df68 --- /dev/null +++ b/Facebook.Unity.Tests/Android/AppInvite.cs @@ -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. + */ + +namespace Facebook.Unity.Tests +{ + using System; + using System.Collections.Generic; + using Facebook.Unity.Mobile.Android; + using NUnit.Framework; + using NUnit.Mocks; + + [TestFixture] + public class AppInvite : FacebookTestClass + { + [Test] + public void TestSimpleAppInvite() + { + var test = new AndroidTest(); + var result = new Dictionary(); + result[Constants.CallbackIdKey] = "1"; + test.ExpectedResult = result; + test.Run( + (callback) => test.AndroidFacebook.AppInvite(null, null, callback), + test.AndroidFacebook.OnAppInviteComplete); + } + } +} diff --git a/Facebook.Unity.Tests/Android/AppLinks.cs b/Facebook.Unity.Tests/Android/AppLinks.cs new file mode 100644 index 000000000..7811be1fa --- /dev/null +++ b/Facebook.Unity.Tests/Android/AppLinks.cs @@ -0,0 +1,135 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Tests +{ + using System; + using System.Collections.Generic; + using NUnit.Framework; + + public class AppLinks : FacebookTestClass + { + [Test] + public void TestAndroidEmptyDefferedAppLink() + { + var test = new AndroidTest(); + var result = new Dictionary(); + result[Constants.CallbackIdKey] = "1"; + result["did_complete"] = true; + test.ExpectedResult = result; + + test.Run( + (callback) => test.AndroidFacebook.FetchDeferredAppLink(callback), + test.AndroidFacebook.OnFetchDeferredAppLinkComplete); + } + + [Test] + public void TestAndroidDeferredAppLink() + { + var test = new AndroidTest(); + var result = new Dictionary(); + result[Constants.CallbackIdKey] = "1"; + result[Constants.RefKey] = "test ref"; + result[Constants.TargetUrlKey] = "test target url"; + result[Constants.ExtrasKey] = new Dictionary() + { + { + "com.facebook.platform.APPLINK_NATIVE_CLASS", string.Empty + }, + { + "target_url", result[Constants.TargetUrlKey] + } + }; + + test.ExpectedResult = result; + + test.CallbackResultValidator = appLinkResult => + { + Assert.IsNotNull(appLinkResult.Extras); + Assert.IsNotNull(appLinkResult.Ref); + Assert.IsNotNull(appLinkResult.TargetUrl); + Assert.IsNull(appLinkResult.Url); + }; + + test.Run( + (callback) => test.AndroidFacebook.FetchDeferredAppLink(callback), + test.AndroidFacebook.OnFetchDeferredAppLinkComplete); + } + + [Test] + public void TestAndroidSimpleDeepLink() + { + var test = new AndroidTest(); + var result = new Dictionary(); + result[Constants.CallbackIdKey] = "1"; + result[Constants.UrlKey] = "test url"; + result[Constants.RefKey] = "test ref"; + result[Constants.TargetUrlKey] = "test target url"; + result[Constants.ExtrasKey] = new Dictionary() + { + { + "extras", new Dictionary() + }, + { + "version", "1.0" + } + }; + + test.ExpectedResult = result; + + test.CallbackResultValidator = appLinkResult => + { + Assert.AreEqual(result[Constants.UrlKey], appLinkResult.Url); + Assert.AreEqual(result[Constants.RefKey], appLinkResult.Ref); + Assert.AreEqual(result[Constants.TargetUrlKey], appLinkResult.TargetUrl); + Assert.AreEqual( + MiniJSON.Json.Serialize(result[Constants.ExtrasKey]), + MiniJSON.Json.Serialize(appLinkResult.Extras)); + }; + + test.Run( + (callback) => test.AndroidFacebook.GetAppLink(callback), + test.AndroidFacebook.OnGetAppLinkComplete); + } + + [Test] + public void TestAndroidAppLink() + { + var test = new AndroidTest(); + var result = new Dictionary(); + result[Constants.CallbackIdKey] = "1"; + result[Constants.UrlKey] = "test url"; + + test.ExpectedResult = result; + + test.CallbackResultValidator = appLinkResult => + { + Assert.AreEqual(result[Constants.UrlKey], appLinkResult.Url); + Assert.IsNull(appLinkResult.Ref); + Assert.IsNull(appLinkResult.TargetUrl); + Assert.IsNull(appLinkResult.Extras); + }; + + test.Run( + (callback) => test.AndroidFacebook.GetAppLink(callback), + test.AndroidFacebook.OnGetAppLinkComplete); + } + } +} diff --git a/Facebook.Unity.Tests/Android/Login.cs b/Facebook.Unity.Tests/Android/Login.cs new file mode 100644 index 000000000..c48701795 --- /dev/null +++ b/Facebook.Unity.Tests/Android/Login.cs @@ -0,0 +1,141 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Tests +{ + using System; + using System.Collections.Generic; + using System.Linq; + using Facebook.Unity.Mobile.Android; + using NUnit.Framework; + using NUnit.Mocks; + + [TestFixture] + public class Login : FacebookTestClass + { + private const string UserID = "100000000000000"; + private const string TestTokenString = "This is a test token string"; + private readonly DateTime expirationTime = DateTime.UtcNow.AddDays(60); + private readonly string[] readPermissions = new string[] + { + Constants.EmailPermission, + Constants.UserLikesPermission + }; + + private readonly string[] publishPermissions = new string[] + { + Constants.PublishActionsPermission, + Constants.PublishPagesPermission + }; + + [Test] + public void BasicLoginWithReadTest() + { + AccessToken.CurrentAccessToken = null; + var test = new AndroidTest(); + var result = this.GetBaseTokenResult(); + test.ExpectedResult = result; + + test.Run( + (callback) => test.AndroidFacebook.LogInWithReadPermissions(null, callback), + test.AndroidFacebook.OnLoginComplete); + this.AssertResultDicMatchesToken(result, AccessToken.CurrentAccessToken); + } + + [Test] + public void BasicLoginWithPublishTest() + { + AccessToken.CurrentAccessToken = null; + var test = new AndroidTest(); + var result = this.GetBaseTokenResult(); + result[LoginResult.PermissionsKey] = string.Join(",", this.publishPermissions); + test.ExpectedResult = result; + + test.Run( + (callback) => test.AndroidFacebook.LogInWithReadPermissions(null, callback), + test.AndroidFacebook.OnLoginComplete); + this.AssertResultDicMatchesToken(result, AccessToken.CurrentAccessToken); + } + + [Test] + public void TestMaxInt64ExpiredTime() + { + AccessToken.CurrentAccessToken = null; + var test = new AndroidTest(); + var result = this.GetBaseTokenResult(); + result[LoginResult.ExpirationTimestampKey] = "9223372036854775"; + test.ExpectedResult = result; + + test.Run( + (callback) => test.AndroidFacebook.LogInWithReadPermissions(null, callback), + test.AndroidFacebook.OnLoginComplete); + + // Check to make sure the access token is set + var expected = new Dictionary(result); + expected[LoginResult.ExpirationTimestampKey] = DateTime.MaxValue.TimeInSeconds().ToString(); + this.AssertResultDicMatchesToken(expected, AccessToken.CurrentAccessToken); + } + + [Test] + public void TestZeroExpiredTime() + { + AccessToken.CurrentAccessToken = null; + var test = new AndroidTest(); + var result = this.GetBaseTokenResult(); + result[LoginResult.ExpirationTimestampKey] = "0"; + test.ExpectedResult = result; + + test.Run( + (callback) => test.AndroidFacebook.LogInWithReadPermissions(null, callback), + test.AndroidFacebook.OnLoginComplete); + + // Check to make sure the access token is set + var expected = new Dictionary(result); + expected[LoginResult.ExpirationTimestampKey] = DateTime.MaxValue.TimeInSeconds().ToString(); + this.AssertResultDicMatchesToken(expected, AccessToken.CurrentAccessToken); + } + + private IDictionary GetBaseTokenResult() + { + var result = new Dictionary(); + result[Constants.CallbackIdKey] = "1"; + result[LoginResult.UserIdKey] = UserID; + result[LoginResult.ExpirationTimestampKey] = this.expirationTime.TimeInSeconds().ToString(); + result[LoginResult.AccessTokenKey] = TestTokenString; + result[LoginResult.PermissionsKey] = string.Join(",", this.readPermissions); + return result; + } + + private void AssertResultDicMatchesToken(IDictionary result, AccessToken token) + { + Assert.AreEqual(result[LoginResult.UserIdKey], AccessToken.CurrentAccessToken.UserId); + Assert.AreEqual( + result[LoginResult.ExpirationTimestampKey], + AccessToken.CurrentAccessToken.ExpirationTime.TimeInSeconds().ToString()); + string permString = (string)result[LoginResult.PermissionsKey]; + foreach (var perm in permString.Split(',')) + { + Assert.IsTrue(AccessToken.CurrentAccessToken.Permissions.ToList().Contains(perm)); + } + + Assert.AreEqual(result[Constants.AccessTokenKey], AccessToken.CurrentAccessToken.TokenString); + } + } +} diff --git a/Facebook.Unity.Tests/Android/MockAndroidJavaClass.cs b/Facebook.Unity.Tests/Android/MockAndroidJavaClass.cs new file mode 100644 index 000000000..38d63e18e --- /dev/null +++ b/Facebook.Unity.Tests/Android/MockAndroidJavaClass.cs @@ -0,0 +1,60 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Tests +{ + using System; + using Facebook.Unity.Mobile.Android; + using NUnit.Framework; + + internal class MockAndroidJavaClass : IAndroidJavaClass + { + private object callbackStaticMethod; + + public delegate void OnResult(string result); + + public OnResult Callback { get; set; } + + public string Result { get; set; } + + public T CallStatic(string methodName) + { + if (this.callbackStaticMethod == null) + { + return default(T); + } + + var method = (Func)this.callbackStaticMethod; + return method(methodName); + } + + public void CallStatic(string methodName, params object[] args) + { + Assert.IsFalse(string.IsNullOrEmpty(methodName)); + Assert.IsFalse(string.IsNullOrEmpty((string)args[0])); + this.Callback(this.Result); + } + + public void SetMethodReplacement(Func method) + { + this.callbackStaticMethod = method; + } + } +} diff --git a/Facebook.Unity.Tests/Android/ShareLink.cs b/Facebook.Unity.Tests/Android/ShareLink.cs new file mode 100644 index 000000000..e6b0995c3 --- /dev/null +++ b/Facebook.Unity.Tests/Android/ShareLink.cs @@ -0,0 +1,53 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Tests +{ + using System; + using System.Collections.Generic; + using Facebook.Unity.Mobile.Android; + using NUnit.Framework; + + public class ShareLink : FacebookTestClass + { + [Test] + public void SimpleLinkShare() + { + var test = new AndroidTest(); + var result = new Dictionary(); + result[Constants.CallbackIdKey] = "1"; + result["id"] = "123456789"; + test.ExpectedResult = result; + test.CallbackResultValidator = (shareResult) => + { + Assert.AreEqual(result["id"], shareResult.PostId); + }; + + test.Run( + (callback) => test.AndroidFacebook.ShareLink( + new Uri("http://www.test.com/"), + "test title", + "test description", + new Uri("http://www.photo.com/"), + callback), + test.AndroidFacebook.OnShareLinkComplete); + } + } +} diff --git a/Facebook.Unity.Tests/Facebook.Unity.Tests.csproj b/Facebook.Unity.Tests/Facebook.Unity.Tests.csproj new file mode 100644 index 000000000..34ad76f26 --- /dev/null +++ b/Facebook.Unity.Tests/Facebook.Unity.Tests.csproj @@ -0,0 +1,67 @@ + + + + Debug + AnyCPU + 10.0.0 + 2.0 + {4A088D45-0F5D-400B-9FF6-5AAF3ED10D9A} + Library + Facebook.Unity.Test + Facebook.Unity.Tests + v4.0 + + + True + full + False + bin\Debug + DEBUG; + prompt + 4 + False + + + none + True + bin\Release + prompt + 4 + False + + + + + {25723619-BB7C-ACF1-BFE7-AEB6DC175F4C} + Assembly-CSharp + + + + + + + + + + + + + + + False + + + False + + + False + + + False + + + + + + + diff --git a/Facebook.Unity.Tests/FacebookTestClass.cs b/Facebook.Unity.Tests/FacebookTestClass.cs new file mode 100644 index 000000000..e0518481a --- /dev/null +++ b/Facebook.Unity.Tests/FacebookTestClass.cs @@ -0,0 +1,58 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Tests +{ + using System; + using NUnit.Framework; + + [TestFixture] + public class FacebookTestClass + { + [SetUp] + public void Init() + { + FacebookLogger.Instance = new FacebookTestLogger(); + } + + private class FacebookTestLogger : IFacebookLogger + { + public void Log(string msg) + { + Console.WriteLine(msg); + } + + public void Info(string msg) + { + Console.WriteLine(msg); + } + + public void Warn(string msg) + { + Console.WriteLine(msg); + } + + public void Error(string msg) + { + Console.WriteLine(msg); + } + } + } +} diff --git a/Facebook.Unity.Tests/Utilities.cs b/Facebook.Unity.Tests/Utilities.cs new file mode 100644 index 000000000..abacce26b --- /dev/null +++ b/Facebook.Unity.Tests/Utilities.cs @@ -0,0 +1,34 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Tests +{ + using System; + + public static class Utilities + { + public static long TimeInSeconds(this DateTime dateTime) + { + TimeSpan t = dateTime - new DateTime(1970, 1, 1); + long secondsSinceEpoch = (long)t.TotalSeconds; + return secondsSinceEpoch; + } + } +} diff --git a/Facebook.Unity/.gitignore b/Facebook.Unity/.gitignore new file mode 100644 index 000000000..3e7e08818 --- /dev/null +++ b/Facebook.Unity/.gitignore @@ -0,0 +1,18 @@ +# Facebook SDK Package + +# Autogenerated VS/MD solution and project files +*.csproj +*.unityproj +*.sln +*.suo +*.tmp +*.user +*.userprefs +*.pidb +*.booproj + +# Unity Temp Files +/[Ll]ibrary/ +/[Tt]emp/ +/[Oo]bj/ +/[Bb]uild/ diff --git a/Facebook.Unity/Assets/Examples.meta b/Facebook.Unity/Assets/Examples.meta new file mode 100644 index 000000000..ef085fff3 --- /dev/null +++ b/Facebook.Unity/Assets/Examples.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 42c218b57d66ee44a896db573c3303ab +folderAsset: yes +DefaultImporter: + userData: diff --git a/Facebook.Unity/Assets/Examples/AppEvents.unity b/Facebook.Unity/Assets/Examples/AppEvents.unity new file mode 100644 index 000000000..3252c6730 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/AppEvents.unity @@ -0,0 +1,213 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: .25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: .5, g: .5, b: .5, a: 1} + m_FogMode: 3 + m_FogDensity: .00999999978 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: .211999997, g: .226999998, b: .259000003, a: 1} + m_AmbientEquatorColor: {r: .114, g: .125, b: .133000001, a: 1} + m_AmbientGroundColor: {r: .0469999984, g: .0430000015, b: .0350000001, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: .5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!127 &3 +LevelGameManager: + m_ObjectHideFlags: 0 +--- !u!157 &4 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 5 + m_GIWorkflowMode: 0 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_LightmapSnapshot: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &5 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: .5 + agentHeight: 2 + agentSlope: 45 + agentClimb: .400000006 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: .166666672 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &17281797 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 17281802} + - 20: {fileID: 17281801} + - 92: {fileID: 17281800} + - 124: {fileID: 17281799} + - 81: {fileID: 17281798} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &17281798 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 +--- !u!124 &17281799 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 +--- !u!92 &17281800 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 +--- !u!20 &17281801 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: .23137255, g: .349019617, b: .596078455, a: 1} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_HDR: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 + m_StereoMirrorMode: 0 +--- !u!4 &17281802 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 +--- !u!1 &1482271768 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1482271770} + - 114: {fileID: 1482271769} + m_Layer: 0 + m_Name: AppEvents + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1482271769 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1482271768} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e3c0dd81ff77c4c30834810815c69f6d, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &1482271770 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1482271768} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -6.42004156, y: -8.74592876, z: -1.64325905} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 diff --git a/Facebook.Unity/Assets/Examples/AppEvents.unity.meta b/Facebook.Unity/Assets/Examples/AppEvents.unity.meta new file mode 100644 index 000000000..1f97042f3 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/AppEvents.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 68ab940fa15e34433bff18301686b080 +timeCreated: 1434663633 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Examples/AppInvites.unity b/Facebook.Unity/Assets/Examples/AppInvites.unity new file mode 100644 index 000000000..bf68f8615 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/AppInvites.unity @@ -0,0 +1,213 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: .25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: .5, g: .5, b: .5, a: 1} + m_FogMode: 3 + m_FogDensity: .00999999978 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: .200000003, g: .200000003, b: .200000003, a: 1} + m_AmbientEquatorColor: {r: .200000003, g: .200000003, b: .200000003, a: 1} + m_AmbientGroundColor: {r: .200000003, g: .200000003, b: .200000003, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 3 + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: .5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!127 &3 +LevelGameManager: + m_ObjectHideFlags: 0 +--- !u!157 &4 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 5 + m_GIWorkflowMode: 1 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 1 + m_BakeResolution: 50 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 0 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_LightmapSnapshot: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &5 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: .5 + agentHeight: 2 + agentSlope: 45 + agentClimb: .400000006 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: .166666657 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &787078726 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 787078731} + - 20: {fileID: 787078730} + - 92: {fileID: 787078729} + - 124: {fileID: 787078728} + - 81: {fileID: 787078727} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &787078727 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 787078726} + m_Enabled: 1 +--- !u!124 &787078728 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 787078726} + m_Enabled: 1 +--- !u!92 &787078729 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 787078726} + m_Enabled: 1 +--- !u!20 &787078730 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 787078726} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: .23137255, g: .349019617, b: .596078455, a: 1} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 100 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_HDR: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 + m_StereoMirrorMode: 0 +--- !u!4 &787078731 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 787078726} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 +--- !u!1 &1988862590 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1988862591} + - 114: {fileID: 1988862593} + m_Layer: 0 + m_Name: AppInvites + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1988862591 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1988862590} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -6.42004156, y: -8.74592876, z: -1.64325905} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &1988862593 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1988862590} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2dd0cfad778f94eecbb977b7abd5a0ec, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Facebook.Unity/Assets/Examples/AppInvites.unity.meta b/Facebook.Unity/Assets/Examples/AppInvites.unity.meta new file mode 100644 index 000000000..cfe9e3092 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/AppInvites.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1beb7e4efae1b4e8d87bb52689540adf +timeCreated: 1437434230 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Examples/AppLinks.unity b/Facebook.Unity/Assets/Examples/AppLinks.unity new file mode 100644 index 000000000..8cb5abf0a --- /dev/null +++ b/Facebook.Unity/Assets/Examples/AppLinks.unity @@ -0,0 +1,213 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: .25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: .5, g: .5, b: .5, a: 1} + m_FogMode: 3 + m_FogDensity: .00999999978 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: .211999997, g: .226999998, b: .259000003, a: 1} + m_AmbientEquatorColor: {r: .114, g: .125, b: .133000001, a: 1} + m_AmbientGroundColor: {r: .0469999984, g: .0430000015, b: .0350000001, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: .5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!127 &3 +LevelGameManager: + m_ObjectHideFlags: 0 +--- !u!157 &4 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 5 + m_GIWorkflowMode: 0 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_LightmapSnapshot: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &5 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: .5 + agentHeight: 2 + agentSlope: 45 + agentClimb: .400000006 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: .166666672 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &17281797 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 17281802} + - 20: {fileID: 17281801} + - 92: {fileID: 17281800} + - 124: {fileID: 17281799} + - 81: {fileID: 17281798} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &17281798 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 +--- !u!124 &17281799 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 +--- !u!92 &17281800 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 +--- !u!20 &17281801 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: .23137255, g: .349019617, b: .596078455, a: 1} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_HDR: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 + m_StereoMirrorMode: 0 +--- !u!4 &17281802 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 +--- !u!1 &1482271768 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1482271770} + - 114: {fileID: 1482271769} + m_Layer: 0 + m_Name: AppLinks + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1482271769 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1482271768} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f9f0b7257fa054227be6e26bf1f6b339, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &1482271770 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1482271768} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -6.42004156, y: -8.74592876, z: -1.64325905} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 diff --git a/Facebook.Unity/Assets/Examples/AppLinks.unity.meta b/Facebook.Unity/Assets/Examples/AppLinks.unity.meta new file mode 100644 index 000000000..327030abe --- /dev/null +++ b/Facebook.Unity/Assets/Examples/AppLinks.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4ac12dfde6570493291366d0ab3eb20d +timeCreated: 1434663633 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Examples/AppRequests.unity b/Facebook.Unity/Assets/Examples/AppRequests.unity new file mode 100644 index 000000000..67d1d906c --- /dev/null +++ b/Facebook.Unity/Assets/Examples/AppRequests.unity @@ -0,0 +1,213 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: .25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: .5, g: .5, b: .5, a: 1} + m_FogMode: 3 + m_FogDensity: .00999999978 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: .211999997, g: .226999998, b: .259000003, a: 1} + m_AmbientEquatorColor: {r: .114, g: .125, b: .133000001, a: 1} + m_AmbientGroundColor: {r: .0469999984, g: .0430000015, b: .0350000001, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: .5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!127 &3 +LevelGameManager: + m_ObjectHideFlags: 0 +--- !u!157 &4 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 5 + m_GIWorkflowMode: 0 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_LightmapSnapshot: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &5 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: .5 + agentHeight: 2 + agentSlope: 45 + agentClimb: .400000006 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: .166666672 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &17281797 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 17281802} + - 20: {fileID: 17281801} + - 92: {fileID: 17281800} + - 124: {fileID: 17281799} + - 81: {fileID: 17281798} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &17281798 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 +--- !u!124 &17281799 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 +--- !u!92 &17281800 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 +--- !u!20 &17281801 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: .23137255, g: .349019617, b: .596078455, a: 1} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_HDR: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 + m_StereoMirrorMode: 0 +--- !u!4 &17281802 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 +--- !u!1 &1482271768 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1482271770} + - 114: {fileID: 1482271769} + m_Layer: 0 + m_Name: AppRequests + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1482271769 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1482271768} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3b4c675f81a254b87adc8ad01006c580, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &1482271770 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1482271768} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -6.42004156, y: -8.74592876, z: -1.64325905} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 diff --git a/Facebook.Unity/Assets/Examples/AppRequests.unity.meta b/Facebook.Unity/Assets/Examples/AppRequests.unity.meta new file mode 100644 index 000000000..e7f8fcf50 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/AppRequests.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c2250c9c5cf00425384401321f8dffb4 +timeCreated: 1434135388 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Examples/DialogShare.unity b/Facebook.Unity/Assets/Examples/DialogShare.unity new file mode 100644 index 000000000..fbf58a169 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/DialogShare.unity @@ -0,0 +1,213 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: .25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: .5, g: .5, b: .5, a: 1} + m_FogMode: 3 + m_FogDensity: .00999999978 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: .211999997, g: .226999998, b: .259000003, a: 1} + m_AmbientEquatorColor: {r: .114, g: .125, b: .133000001, a: 1} + m_AmbientGroundColor: {r: .0469999984, g: .0430000015, b: .0350000001, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: .5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!127 &3 +LevelGameManager: + m_ObjectHideFlags: 0 +--- !u!157 &4 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 5 + m_GIWorkflowMode: 0 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_LightmapSnapshot: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &5 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: .5 + agentHeight: 2 + agentSlope: 45 + agentClimb: .400000006 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: .166666672 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &17281797 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 17281802} + - 20: {fileID: 17281801} + - 92: {fileID: 17281800} + - 124: {fileID: 17281799} + - 81: {fileID: 17281798} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &17281798 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 +--- !u!124 &17281799 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 +--- !u!92 &17281800 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 +--- !u!20 &17281801 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: .23137255, g: .349019617, b: .596078455, a: 1} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_HDR: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 + m_StereoMirrorMode: 0 +--- !u!4 &17281802 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 +--- !u!1 &1482271768 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1482271770} + - 114: {fileID: 1482271769} + m_Layer: 0 + m_Name: DialogShare + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1482271769 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1482271768} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e93c4155902d3496399630ee494eab6b, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &1482271770 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1482271768} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -6.42004156, y: -8.74592876, z: -1.64325905} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 diff --git a/Facebook.Unity/Assets/Examples/DialogShare.unity.meta b/Facebook.Unity/Assets/Examples/DialogShare.unity.meta new file mode 100644 index 000000000..1942f703e --- /dev/null +++ b/Facebook.Unity/Assets/Examples/DialogShare.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 190c345841ecc464e9a122f04369757e +timeCreated: 1434132966 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Examples/GameGroups.unity b/Facebook.Unity/Assets/Examples/GameGroups.unity new file mode 100644 index 000000000..7c8b60c6b --- /dev/null +++ b/Facebook.Unity/Assets/Examples/GameGroups.unity @@ -0,0 +1,218 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: .25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: .5, g: .5, b: .5, a: 1} + m_FogMode: 3 + m_FogDensity: .00999999978 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: .211999997, g: .226999998, b: .259000003, a: 1} + m_AmbientEquatorColor: {r: .114, g: .125, b: .133000001, a: 1} + m_AmbientGroundColor: {r: .0469999984, g: .0430000015, b: .0350000001, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: .5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!127 &3 +LevelGameManager: + m_ObjectHideFlags: 0 +--- !u!157 &4 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 5 + m_GIWorkflowMode: 0 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_LightmapSnapshot: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &5 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: .5 + agentHeight: 2 + agentSlope: 45 + agentClimb: .400000006 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: .166666672 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &17281797 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 17281802} + - 20: {fileID: 17281801} + - 92: {fileID: 17281800} + - 124: {fileID: 17281799} + - 81: {fileID: 17281798} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &17281798 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 +--- !u!124 &17281799 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 +--- !u!92 &17281800 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 +--- !u!20 &17281801 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: .23137255, g: .349019617, b: .596078455, a: 1} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_HDR: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 + m_StereoMirrorMode: 0 +--- !u!4 &17281802 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 +--- !u!1 &1482271768 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1482271770} + - 114: {fileID: 1482271769} + m_Layer: 0 + m_Name: GameGroups + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1482271769 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1482271768} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: db1bc390317cb4b799efac28a460ea64, type: 3} + m_Name: + m_EditorClassIdentifier: + GamerGroupName: Test group + GamerGroupDesc: Test group for testing. + GamerGroupPrivacy: closed + GamerGroupAdmin: + GamerGroupCurrentGroup: +--- !u!4 &1482271770 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1482271768} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -6.42004156, y: -8.74592876, z: -1.64325905} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 diff --git a/Facebook.Unity/Assets/Examples/GameGroups.unity.meta b/Facebook.Unity/Assets/Examples/GameGroups.unity.meta new file mode 100644 index 000000000..5a6e55aa6 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/GameGroups.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7d6bb338e749741f1a68b006a0476e89 +timeCreated: 1434139631 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Examples/GraphRequest.unity b/Facebook.Unity/Assets/Examples/GraphRequest.unity new file mode 100644 index 000000000..c9b56503d --- /dev/null +++ b/Facebook.Unity/Assets/Examples/GraphRequest.unity @@ -0,0 +1,213 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: .25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: .5, g: .5, b: .5, a: 1} + m_FogMode: 3 + m_FogDensity: .00999999978 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: .211999997, g: .226999998, b: .259000003, a: 1} + m_AmbientEquatorColor: {r: .114, g: .125, b: .133000001, a: 1} + m_AmbientGroundColor: {r: .0469999984, g: .0430000015, b: .0350000001, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: .5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!127 &3 +LevelGameManager: + m_ObjectHideFlags: 0 +--- !u!157 &4 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 5 + m_GIWorkflowMode: 0 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_LightmapSnapshot: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &5 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: .5 + agentHeight: 2 + agentSlope: 45 + agentClimb: .400000006 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: .166666672 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &17281797 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 17281802} + - 20: {fileID: 17281801} + - 92: {fileID: 17281800} + - 124: {fileID: 17281799} + - 81: {fileID: 17281798} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &17281798 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 +--- !u!124 &17281799 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 +--- !u!92 &17281800 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 +--- !u!20 &17281801 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: .23137255, g: .349019617, b: .596078455, a: 1} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_HDR: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 + m_StereoMirrorMode: 0 +--- !u!4 &17281802 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 +--- !u!1 &1482271768 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1482271770} + - 114: {fileID: 1482271769} + m_Layer: 0 + m_Name: GraphRequest + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1482271769 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1482271768} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 23c3cb06c2209474e9a8441e2712d5d2, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &1482271770 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1482271768} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -6.42004156, y: -8.74592876, z: -1.64325905} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 diff --git a/Facebook.Unity/Assets/Examples/GraphRequest.unity.meta b/Facebook.Unity/Assets/Examples/GraphRequest.unity.meta new file mode 100644 index 000000000..c55461694 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/GraphRequest.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 444ae7ddf432b457a97bfe42021075e3 +timeCreated: 1434488369 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Examples/LogView.unity b/Facebook.Unity/Assets/Examples/LogView.unity new file mode 100644 index 000000000..5e5e64759 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/LogView.unity @@ -0,0 +1,213 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: .25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: .5, g: .5, b: .5, a: 1} + m_FogMode: 3 + m_FogDensity: .00999999978 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: .211999997, g: .226999998, b: .259000003, a: 1} + m_AmbientEquatorColor: {r: .114, g: .125, b: .133000001, a: 1} + m_AmbientGroundColor: {r: .0469999984, g: .0430000015, b: .0350000001, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: .5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!127 &3 +LevelGameManager: + m_ObjectHideFlags: 0 +--- !u!157 &4 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 5 + m_GIWorkflowMode: 0 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_LightmapSnapshot: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &5 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: .5 + agentHeight: 2 + agentSlope: 45 + agentClimb: .400000006 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: .166666672 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &17281797 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 17281802} + - 20: {fileID: 17281801} + - 92: {fileID: 17281800} + - 124: {fileID: 17281799} + - 81: {fileID: 17281798} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &17281798 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 +--- !u!124 &17281799 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 +--- !u!92 &17281800 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 +--- !u!20 &17281801 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: .23137255, g: .349019617, b: .596078455, a: 1} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_HDR: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 + m_StereoMirrorMode: 0 +--- !u!4 &17281802 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 17281797} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 +--- !u!1 &1482271768 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1482271770} + - 114: {fileID: 1482271769} + m_Layer: 0 + m_Name: LogView + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1482271769 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1482271768} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 910cbe16250cb4363b70464c39fc701a, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &1482271770 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1482271768} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -6.42004156, y: -8.74592876, z: -1.64325905} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 diff --git a/Facebook.Unity/Assets/Examples/LogView.unity.meta b/Facebook.Unity/Assets/Examples/LogView.unity.meta new file mode 100644 index 000000000..ac61c4ce0 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/LogView.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c07ff0bf6bea74c2eb681ac0cae44265 +timeCreated: 1434143106 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Examples/MainMenu.unity b/Facebook.Unity/Assets/Examples/MainMenu.unity new file mode 100644 index 000000000..915e4d058 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/MainMenu.unity @@ -0,0 +1,213 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: .25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: .5, g: .5, b: .5, a: 1} + m_FogMode: 3 + m_FogDensity: .00999999978 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: .200000003, g: .200000003, b: .200000003, a: 1} + m_AmbientEquatorColor: {r: .200000003, g: .200000003, b: .200000003, a: 1} + m_AmbientGroundColor: {r: .200000003, g: .200000003, b: .200000003, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 3 + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: .5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!127 &3 +LevelGameManager: + m_ObjectHideFlags: 0 +--- !u!157 &4 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 5 + m_GIWorkflowMode: 1 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 1 + m_BakeResolution: 50 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 0 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_LightmapSnapshot: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &5 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: .5 + agentHeight: 2 + agentSlope: 45 + agentClimb: .400000006 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: .166666657 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &787078726 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 787078731} + - 20: {fileID: 787078730} + - 92: {fileID: 787078729} + - 124: {fileID: 787078728} + - 81: {fileID: 787078727} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &787078727 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 787078726} + m_Enabled: 1 +--- !u!124 &787078728 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 787078726} + m_Enabled: 1 +--- !u!92 &787078729 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 787078726} + m_Enabled: 1 +--- !u!20 &787078730 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 787078726} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: .23137255, g: .349019617, b: .596078455, a: 1} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 100 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_HDR: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 + m_StereoMirrorMode: 0 +--- !u!4 &787078731 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 787078726} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 +--- !u!1 &1988862590 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1988862591} + - 114: {fileID: 1988862593} + m_Layer: 0 + m_Name: MainMenu + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1988862591 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1988862590} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -6.42004156, y: -8.74592876, z: -1.64325905} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &1988862593 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1988862590} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 922e3ad8d88a146b3b392cd8c84edd6a, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Facebook.Unity/Assets/Examples/MainMenu.unity.meta b/Facebook.Unity/Assets/Examples/MainMenu.unity.meta new file mode 100644 index 000000000..2329b6881 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/MainMenu.unity.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: 7c38a8c9adc9d5c4b869612e4033ead8 +DefaultImporter: + userData: diff --git a/Facebook.Unity/Assets/Examples/Pay.unity b/Facebook.Unity/Assets/Examples/Pay.unity new file mode 100644 index 000000000..0bdddedc3 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Pay.unity @@ -0,0 +1,213 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: .25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: .5, g: .5, b: .5, a: 1} + m_FogMode: 3 + m_FogDensity: .00999999978 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: .200000003, g: .200000003, b: .200000003, a: 1} + m_AmbientEquatorColor: {r: .200000003, g: .200000003, b: .200000003, a: 1} + m_AmbientGroundColor: {r: .200000003, g: .200000003, b: .200000003, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 3 + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: .5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!157 &4 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 5 + m_GIWorkflowMode: 1 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 1 + m_BakeResolution: 50 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 0 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_ReflectionCompression: 2 + m_LightmapSnapshot: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &5 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: .5 + agentHeight: 2 + agentSlope: 45 + agentClimb: .400000006 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: .166666657 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &787078726 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 787078731} + - 20: {fileID: 787078730} + - 92: {fileID: 787078729} + - 124: {fileID: 787078728} + - 81: {fileID: 787078727} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &787078727 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 787078726} + m_Enabled: 1 +--- !u!124 &787078728 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 787078726} + m_Enabled: 1 +--- !u!92 &787078729 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 787078726} + m_Enabled: 1 +--- !u!20 &787078730 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 787078726} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: .23137255, g: .349019617, b: .596078455, a: 1} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 100 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 + m_StereoMirrorMode: 0 +--- !u!4 &787078731 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 787078726} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 +--- !u!1 &1988862590 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1988862591} + - 114: {fileID: 1988862593} + m_Layer: 0 + m_Name: Pay + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1988862591 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1988862590} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -6.42004156, y: -8.74592876, z: -1.64325905} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &1988862593 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1988862590} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7f08c9721703046ec883e57562184726, type: 3} + m_Name: + m_EditorClassIdentifier: + PayProduct: diff --git a/Facebook.Unity/Assets/Examples/Pay.unity.meta b/Facebook.Unity/Assets/Examples/Pay.unity.meta new file mode 100644 index 000000000..5a7260371 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Pay.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3ee189cdb21ea4bdb9d7022a0780c44c +timeCreated: 1441927990 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Examples/Scripts.meta b/Facebook.Unity/Assets/Examples/Scripts.meta new file mode 100644 index 000000000..c6149ab9b --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 245ad2f8ece194b4a95693b6d4ce4940 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Facebook.Unity/Assets/Examples/Scripts/ConsoleBase.cs b/Facebook.Unity/Assets/Examples/Scripts/ConsoleBase.cs new file mode 100644 index 000000000..1f7bfab88 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/ConsoleBase.cs @@ -0,0 +1,241 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Example +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using UnityEngine; + + internal class ConsoleBase : MonoBehaviour + { + #if UNITY_IOS || UNITY_ANDROID || UNITY_WP8 + protected const int ButtonHeight = 60; + protected static int MainWindowWidth = Screen.width - 30; + protected static int MainWindowFullWidth = Screen.width; + #else + protected const int ButtonHeight = 24; + protected const int MainWindowWidth = 700; + protected const int MainWindowFullWidth = 760; + #endif + + private const int DpiScalingFactor = 160; + private static Stack menuStack = new Stack(); + private string status = "Ready"; + private string lastResponse = string.Empty; + private Vector2 scrollPosition = Vector2.zero; + + // DPI scaling + private float? scaleFactor; + private GUIStyle textStyle; + private GUIStyle buttonStyle; + private GUIStyle textInputStyle; + private GUIStyle labelStyle; + + protected static Stack MenuStack + { + get + { + return ConsoleBase.menuStack; + } + + set + { + ConsoleBase.menuStack = value; + } + } + + protected string Status + { + get + { + return this.status; + } + + set + { + this.status = value; + } + } + + protected Texture2D LastResponseTexture { get; set; } + + protected string LastResponse + { + get + { + return this.lastResponse; + } + + set + { + this.lastResponse = value; + } + } + + protected Vector2 ScrollPosition + { + get + { + return this.scrollPosition; + } + + set + { + this.scrollPosition = value; + } + } + + // Note we assume that these styles will be accessed from OnGUI otherwise the + // unity APIs will fail. + protected float ScaleFactor + { + get + { + if (!this.scaleFactor.HasValue) + { + this.scaleFactor = Screen.dpi / ConsoleBase.DpiScalingFactor; + } + + return this.scaleFactor.Value; + } + } + + protected int FontSize + { + get + { + return (int)Math.Round(this.ScaleFactor * 16); + } + } + + protected GUIStyle TextStyle + { + get + { + if (this.textStyle == null) + { + this.textStyle = new GUIStyle(GUI.skin.textArea); + this.textStyle.alignment = TextAnchor.UpperLeft; + this.textStyle.wordWrap = true; + this.textStyle.padding = new RectOffset(10, 10, 10, 10); + this.textStyle.stretchHeight = true; + this.textStyle.stretchWidth = false; + this.textStyle.fontSize = this.FontSize; + } + + return this.textStyle; + } + } + + protected GUIStyle ButtonStyle + { + get + { + if (this.buttonStyle == null) + { + this.buttonStyle = new GUIStyle(GUI.skin.button); + this.buttonStyle.fontSize = this.FontSize; + } + + return this.buttonStyle; + } + } + + protected GUIStyle TextInputStyle + { + get + { + if (this.textInputStyle == null) + { + this.textInputStyle = new GUIStyle(GUI.skin.textField); + this.textInputStyle.fontSize = this.FontSize; + } + + return this.textInputStyle; + } + } + + protected GUIStyle LabelStyle + { + get + { + if (this.labelStyle == null) + { + this.labelStyle = new GUIStyle(GUI.skin.label); + this.labelStyle.fontSize = this.FontSize; + } + + return this.labelStyle; + } + } + + protected virtual void Awake() + { + // Limit the framerate to 60 to keep device from burning through cpu + Application.targetFrameRate = 60; + } + + protected bool Button(string label) + { + return GUILayout.Button( + label, + this.ButtonStyle, + GUILayout.MinHeight(ConsoleBase.ButtonHeight * this.ScaleFactor), + GUILayout.MaxWidth(ConsoleBase.MainWindowWidth)); + } + + protected void LabelAndTextField(string label, ref string text) + { + GUILayout.BeginHorizontal(); + GUILayout.Label(label, this.LabelStyle, GUILayout.MaxWidth(200 * this.ScaleFactor)); + text = GUILayout.TextField( + text, + this.TextInputStyle, + GUILayout.MaxWidth(ConsoleBase.MainWindowWidth - 150)); + GUILayout.EndHorizontal(); + } + + protected bool IsHorizontalLayout() + { + #if UNITY_IOS || UNITY_ANDROID || UNITY_WP8 + return Screen.orientation == ScreenOrientation.Landscape; + #else + return true; + #endif + } + + protected void SwitchMenu(Type menuClass) + { + ConsoleBase.menuStack.Push(this.GetType().Name); + Application.LoadLevel(menuClass.Name); + } + + protected void GoBack() + { + if (ConsoleBase.menuStack.Any()) + { + Application.LoadLevel(ConsoleBase.menuStack.Pop()); + } + } + } +} diff --git a/Facebook.Unity/Assets/Examples/Scripts/ConsoleBase.cs.meta b/Facebook.Unity/Assets/Examples/Scripts/ConsoleBase.cs.meta new file mode 100644 index 000000000..a428b8ffa --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/ConsoleBase.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e8659f5605d094c19a8b7ef9471c3603 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Facebook.Unity/Assets/Examples/Scripts/LogView.cs b/Facebook.Unity/Assets/Examples/Scripts/LogView.cs new file mode 100644 index 000000000..615b5aaec --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/LogView.cs @@ -0,0 +1,72 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Example +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Text; + + using UnityEngine; + + internal class LogView : ConsoleBase + { + private static string datePatt = @"M/d/yyyy hh:mm:ss tt"; + private static IList events = new List(); + + public static void AddLog(string log) + { + events.Insert(0, string.Format("{0}\n{1}\n", DateTime.Now.ToString(datePatt), log)); + } + + protected void OnGUI() + { + GUILayout.BeginVertical(); + if (this.Button("Back")) + { + this.GoBack(); + } + + #if UNITY_IOS || UNITY_ANDROID || UNITY_WP8 + if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) + { + Vector2 scrollPosition = this.ScrollPosition; + scrollPosition.y += Input.GetTouch(0).deltaPosition.y; + this.ScrollPosition = scrollPosition; + } + #endif + this.ScrollPosition = GUILayout.BeginScrollView( + this.ScrollPosition, + GUILayout.MinWidth(ConsoleBase.MainWindowFullWidth)); + + GUILayout.TextArea( + string.Join("\n", events.ToArray()), + this.TextStyle, + GUILayout.ExpandHeight(true), + GUILayout.MaxWidth(ConsoleBase.MainWindowWidth)); + + GUILayout.EndScrollView(); + + GUILayout.EndVertical(); + } + } +} diff --git a/Facebook.Unity/Assets/Examples/Scripts/LogView.cs.meta b/Facebook.Unity/Assets/Examples/Scripts/LogView.cs.meta new file mode 100644 index 000000000..4d9123fb5 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/LogView.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 910cbe16250cb4363b70464c39fc701a +timeCreated: 1434143113 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Examples/Scripts/MenuBase.cs b/Facebook.Unity/Assets/Examples/Scripts/MenuBase.cs new file mode 100644 index 000000000..1063e7054 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/MenuBase.cs @@ -0,0 +1,178 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Example +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using UnityEngine; + + internal abstract class MenuBase : ConsoleBase + { + private static ShareDialogMode shareDialogMode; + + protected abstract void GetGui(); + + protected virtual bool ShowDialogModeSelector() + { + return false; + } + + protected virtual bool ShowBackButton() + { + return true; + } + + protected void HandleResult(IResult result) + { + if (result == null) + { + this.LastResponse = "Null Response\n"; + LogView.AddLog(this.LastResponse); + return; + } + + this.LastResponseTexture = null; + + // Some platforms return the empty string instead of null. + if (!string.IsNullOrEmpty(result.Error)) + { + this.Status = "Error - Check log for details"; + this.LastResponse = "Error Response:\n" + result.Error; + LogView.AddLog(result.Error); + } + else if (result.Cancelled) + { + this.Status = "Cancelled - Check log for details"; + this.LastResponse = "Cancelled Response:\n" + result.RawResult; + LogView.AddLog(result.RawResult); + } + else if (!string.IsNullOrEmpty(result.RawResult)) + { + this.Status = "Success - Check log for details"; + this.LastResponse = "Success Response:\n" + result.RawResult; + LogView.AddLog(result.RawResult); + } + else + { + this.LastResponse = "Empty Response\n"; + LogView.AddLog(this.LastResponse); + } + } + + protected void OnGUI() + { + if (this.IsHorizontalLayout()) + { + GUILayout.BeginHorizontal(); + GUILayout.BeginVertical(); + } + + GUILayout.Label(this.GetType().Name, this.LabelStyle); + + this.AddStatus(); + + #if UNITY_IOS || UNITY_ANDROID || UNITY_WP8 + if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) + { + Vector2 scrollPosition = this.ScrollPosition; + scrollPosition.y += Input.GetTouch(0).deltaPosition.y; + this.ScrollPosition = scrollPosition; + } + #endif + this.ScrollPosition = GUILayout.BeginScrollView( + this.ScrollPosition, + GUILayout.MinWidth(ConsoleBase.MainWindowFullWidth)); + + GUILayout.BeginHorizontal(); + if (this.ShowBackButton()) + { + this.AddBackButton(); + } + + this.AddLogButton(); + GUILayout.EndHorizontal(); + if (this.ShowDialogModeSelector()) + { + this.AddDialogModeButtons(); + } + + GUILayout.BeginVertical(); + + // Add the ui from decendants + this.GetGui(); + GUILayout.Space(10); + + GUILayout.EndVertical(); + GUILayout.EndScrollView(); + } + + private void AddStatus() + { + GUILayout.Space(5); + GUILayout.Box("Status: " + this.Status, this.TextStyle, GUILayout.MinWidth(ConsoleBase.MainWindowWidth)); + } + + private void AddBackButton() + { + GUI.enabled = ConsoleBase.MenuStack.Any(); + if (this.Button("Back")) + { + this.GoBack(); + } + + GUI.enabled = true; + } + + private void AddLogButton() + { + if (this.Button("Log")) + { + this.SwitchMenu(typeof(LogView)); + } + } + + private void AddDialogModeButtons() + { + GUILayout.BeginHorizontal(); + foreach (var value in Enum.GetValues(typeof(ShareDialogMode))) + { + this.AddDialogModeButton((ShareDialogMode)value); + } + + GUILayout.EndHorizontal(); + } + + private void AddDialogModeButton(ShareDialogMode mode) + { + bool enabled = GUI.enabled; + GUI.enabled = enabled && (mode != shareDialogMode); + if (this.Button(mode.ToString())) + { + shareDialogMode = mode; + FB.Mobile.ShareDialogMode = mode; + } + + GUI.enabled = enabled; + } + } +} diff --git a/Facebook.Unity/Assets/Examples/Scripts/MenuBase.cs.meta b/Facebook.Unity/Assets/Examples/Scripts/MenuBase.cs.meta new file mode 100644 index 000000000..91c3bbad3 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/MenuBase.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8f28f9112a7d44d3c999fbd95333abbb +timeCreated: 1434135564 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Examples/Scripts/SubMenus.meta b/Facebook.Unity/Assets/Examples/Scripts/SubMenus.meta new file mode 100644 index 000000000..6a5271428 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/SubMenus.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 4f657106417b64d7f85c25c133644bae +folderAsset: yes +timeCreated: 1434135521 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppEvents.cs b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppEvents.cs new file mode 100644 index 000000000..133c6a58c --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppEvents.cs @@ -0,0 +1,47 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Example +{ + using System.Collections; + using System.Collections.Generic; + using UnityEngine; + + internal class AppEvents : MenuBase + { + protected override void GetGui() + { + if (this.Button("Log FB App Event")) + { + this.Status = "Logged FB.AppEvent"; + FB.LogAppEvent( + AppEventName.UnlockedAchievement, + null, + new Dictionary() + { + { AppEventParameterName.Description, "Clicked 'Log AppEvent' button" } + }); + LogView.AddLog( + "You may see results showing up at https://www.facebook.com/analytics/" + + FB.AppId); + } + } + } +} diff --git a/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppEvents.cs.meta b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppEvents.cs.meta new file mode 100644 index 000000000..dc71cd422 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppEvents.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e3c0dd81ff77c4c30834810815c69f6d +timeCreated: 1435018470 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppInvites.cs b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppInvites.cs new file mode 100644 index 000000000..c61e3f1a7 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppInvites.cs @@ -0,0 +1,56 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Example +{ + using System; + using System.Collections; + using UnityEngine; + + internal class AppInvites : MenuBase + { + protected override void GetGui() + { + if (this.Button("Android Invite")) + { + this.Status = "Logged FB.AppEvent"; + FB.Mobile.AppInvite(new Uri("https://fb.me/892708710750483"), callback: this.HandleResult); + } + + if (this.Button("Android Invite With Custom Image")) + { + this.Status = "Logged FB.AppEvent"; + FB.Mobile.AppInvite(new Uri("https://fb.me/892708710750483"), new Uri("http://i.imgur.com/zkYlB.jpg"), this.HandleResult); + } + + if (this.Button("iOS Invite")) + { + this.Status = "Logged FB.AppEvent"; + FB.Mobile.AppInvite(new Uri("https://fb.me/810530068992919"), callback: this.HandleResult); + } + + if (this.Button("iOS Invite With Custom Image")) + { + this.Status = "Logged FB.AppEvent"; + FB.Mobile.AppInvite(new Uri("https://fb.me/810530068992919"), new Uri("http://i.imgur.com/zkYlB.jpg"), this.HandleResult); + } + } + } +} diff --git a/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppInvites.cs.meta b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppInvites.cs.meta new file mode 100644 index 000000000..55b165253 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppInvites.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2dd0cfad778f94eecbb977b7abd5a0ec +timeCreated: 1437434195 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppLinks.cs b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppLinks.cs new file mode 100644 index 000000000..ea4ec2b90 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppLinks.cs @@ -0,0 +1,41 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Example +{ + using System.Collections; + using UnityEngine; + + internal class AppLinks : MenuBase + { + protected override void GetGui() + { + if (this.Button("Get App Link")) + { + FB.GetAppLink(this.HandleResult); + } + + if (Constants.IsMobile && this.Button("Fetch Deferred App Link")) + { + FB.Mobile.FetchDeferredAppLinkData(this.HandleResult); + } + } + } +} diff --git a/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppLinks.cs.meta b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppLinks.cs.meta new file mode 100644 index 000000000..525aa840a --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppLinks.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f9f0b7257fa054227be6e26bf1f6b339 +timeCreated: 1435164891 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppRequests.cs b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppRequests.cs new file mode 100644 index 000000000..b81848233 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppRequests.cs @@ -0,0 +1,144 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Example +{ + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using UnityEngine; + + internal class AppRequests : MenuBase + { + private string requestMessage = string.Empty; + private string requestTo = string.Empty; + private string requestFilter = string.Empty; + private string requestExcludes = string.Empty; + private string requestMax = string.Empty; + private string requestData = string.Empty; + private string requestTitle = string.Empty; + private string requestObjectID = string.Empty; + private int selectedAction = 0; + private string[] actionTypeStrings = + { + "NONE", + OGActionType.SEND.ToString(), + OGActionType.ASKFOR.ToString(), + OGActionType.TURN.ToString() + }; + + protected override void GetGui() + { + if (this.Button("Select - Filter None")) + { + FB.AppRequest("Test Message", callback: this.HandleResult); + } + + if (this.Button("Select - Filter app_users")) + { + List filter = new List() { "app_users" }; + + // workaround for mono failing with named parameters + FB.AppRequest("Test Message", null, filter, null, 0, string.Empty, string.Empty, this.HandleResult); + } + + if (this.Button("Select - Filter app_non_users")) + { + List filter = new List() { "app_non_users" }; + FB.AppRequest("Test Message", null, filter, null, 0, string.Empty, string.Empty, this.HandleResult); + } + + // Custom options + this.LabelAndTextField("Message: ", ref this.requestMessage); + this.LabelAndTextField("To (optional): ", ref this.requestTo); + this.LabelAndTextField("Filter (optional): ", ref this.requestFilter); + this.LabelAndTextField("Exclude Ids (optional): ", ref this.requestExcludes); + this.LabelAndTextField("Filters: ", ref this.requestExcludes); + this.LabelAndTextField("Max Recipients (optional): ", ref this.requestMax); + this.LabelAndTextField("Data (optional): ", ref this.requestData); + this.LabelAndTextField("Title (optional): ", ref this.requestTitle); + + GUILayout.BeginHorizontal(); + GUILayout.Label( + "Request Action (optional): ", + this.LabelStyle, + GUILayout.MaxWidth(200 * this.ScaleFactor)); + + this.selectedAction = GUILayout.Toolbar( + this.selectedAction, + this.actionTypeStrings, + this.ButtonStyle, + GUILayout.MinHeight(ConsoleBase.ButtonHeight * this.ScaleFactor), + GUILayout.MaxWidth(ConsoleBase.MainWindowWidth - 150)); + + GUILayout.EndHorizontal(); + this.LabelAndTextField("Request Object ID (optional): ", ref this.requestObjectID); + + if (this.Button("Custom App Request")) + { + OGActionType? action = this.GetSelectedOGActionType(); + if (action != null) + { + FB.AppRequest( + this.requestMessage, + action.Value, + this.requestObjectID, + this.requestTo != null ? this.requestTo.Split(',') : null, + this.requestData, + this.requestTitle, + this.HandleResult); + } + else + { + FB.AppRequest( + this.requestMessage, + string.IsNullOrEmpty(this.requestTo) ? null : this.requestTo.Split(','), + string.IsNullOrEmpty(this.requestFilter) ? null : this.requestFilter.Split(',').OfType().ToList(), + string.IsNullOrEmpty(this.requestExcludes) ? null : this.requestExcludes.Split(','), + string.IsNullOrEmpty(this.requestMax) ? 0 : int.Parse(this.requestMax), + this.requestData, + this.requestTitle, + this.HandleResult); + } + } + } + + private OGActionType? GetSelectedOGActionType() + { + string actionString = this.actionTypeStrings[this.selectedAction]; + if (actionString == OGActionType.SEND.ToString()) + { + return OGActionType.SEND; + } + else if (actionString == OGActionType.ASKFOR.ToString()) + { + return OGActionType.ASKFOR; + } + else if (actionString == OGActionType.TURN.ToString()) + { + return OGActionType.TURN; + } + else + { + return null; + } + } + } +} diff --git a/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppRequests.cs.meta b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppRequests.cs.meta new file mode 100644 index 000000000..9cd814744 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/AppRequests.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3b4c675f81a254b87adc8ad01006c580 +timeCreated: 1435018470 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Examples/Scripts/SubMenus/DialogShare.cs b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/DialogShare.cs new file mode 100644 index 000000000..7ce828dd7 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/DialogShare.cs @@ -0,0 +1,121 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Example +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using UnityEngine; + + internal class DialogShare : MenuBase + { + // Custom Share Link + private string shareLink = "https://developers.facebook.com/"; + private string shareTitle = "Link Title"; + private string shareDescription = "Link Description"; + private string shareImage = "http://i.imgur.com/j4M7vCO.jpg"; + + // Custom Feed Share + private string feedTo = string.Empty; + private string feedLink = "https://developers.facebook.com/"; + private string feedTitle = "Test Title"; + private string feedCaption = "Test Caption"; + private string feedDescription = "Test Description"; + private string feedImage = "http://i.imgur.com/zkYlB.jpg"; + private string feedMediaSource = string.Empty; + + protected override bool ShowDialogModeSelector() + { + #if !UNITY_EDITOR && (UNITY_IOS || UNITY_ANDROID) + return true; + #else + return false; + #endif + } + + protected override void GetGui() + { + if (this.Button("Share - Link")) + { + FB.ShareLink(new Uri("https://developers.facebook.com/"), callback: this.HandleResult); + } + + // Note: Web dialog doesn't support photo urls. + if (this.Button("Share - Link Photo")) + { + FB.ShareLink( + new Uri("https://developers.facebook.com/"), + "Link Share", + "Look I'm sharing a link", + new Uri("http://i.imgur.com/j4M7vCO.jpg"), + callback: this.HandleResult); + } + + this.LabelAndTextField("Link", ref this.shareLink); + this.LabelAndTextField("Title", ref this.shareTitle); + this.LabelAndTextField("Description", ref this.shareDescription); + this.LabelAndTextField("Image", ref this.shareImage); + if (this.Button("Share - Custom")) + { + FB.ShareLink( + new Uri(this.shareLink), + this.shareTitle, + this.shareDescription, + new Uri(this.shareImage), + this.HandleResult); + } + + if (this.Button("Feed Share - No To")) + { + FB.FeedShare( + string.Empty, + new Uri("https://developers.facebook.com/"), + "Test Title", + "Test caption", + "Test Description", + new Uri("http://i.imgur.com/zkYlB.jpg"), + string.Empty, + this.HandleResult); + } + + this.LabelAndTextField("To", ref this.feedTo); + this.LabelAndTextField("Link", ref this.feedLink); + this.LabelAndTextField("Title", ref this.feedTitle); + this.LabelAndTextField("Caption", ref this.feedCaption); + this.LabelAndTextField("Description", ref this.feedDescription); + this.LabelAndTextField("Image", ref this.feedImage); + this.LabelAndTextField("Media Source", ref this.feedMediaSource); + if (this.Button("Feed Share - Custom")) + { + FB.FeedShare( + this.feedTo, + string.IsNullOrEmpty(this.feedLink) ? null : new Uri(this.feedLink), + this.feedTitle, + this.feedCaption, + this.feedDescription, + string.IsNullOrEmpty(this.feedImage) ? null : new Uri(this.feedImage), + this.feedMediaSource, + this.HandleResult); + } + } + } +} diff --git a/Facebook.Unity/Assets/Examples/Scripts/SubMenus/DialogShare.cs.meta b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/DialogShare.cs.meta new file mode 100644 index 000000000..bb1c78362 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/DialogShare.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e93c4155902d3496399630ee494eab6b +timeCreated: 1435018470 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Examples/Scripts/SubMenus/GameGroups.cs b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/GameGroups.cs new file mode 100644 index 000000000..d195553c0 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/GameGroups.cs @@ -0,0 +1,162 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Example +{ + using System; + using System.Collections; + using System.Collections.Generic; + using UnityEngine; + + internal class GameGroups : MenuBase + { + private string gamerGroupName = "Test group"; + private string gamerGroupDesc = "Test group for testing."; + private string gamerGroupPrivacy = "closed"; + private string gamerGroupCurrentGroup = string.Empty; + + protected override void GetGui() + { + if (this.Button("Game Group Create - Closed")) + { + FB.GameGroupCreate( + "Test game group", + "Test description", + "CLOSED", + this.HandleResult); + } + + if (this.Button("Game Group Create - Open")) + { + FB.GameGroupCreate( + "Test game group", + "Test description", + "OPEN", + this.HandleResult); + } + + this.LabelAndTextField("Group Name", ref this.gamerGroupName); + this.LabelAndTextField("Group Description", ref this.gamerGroupDesc); + this.LabelAndTextField("Group Privacy", ref this.gamerGroupPrivacy); + + if (this.Button("Call Create Group Dialog")) + { + this.CallCreateGroupDialog(); + } + + this.LabelAndTextField("Group To Join", ref this.gamerGroupCurrentGroup); + bool enabled = GUI.enabled; + GUI.enabled = enabled && !string.IsNullOrEmpty(this.gamerGroupCurrentGroup); + if (this.Button("Call Join Group Dialog")) + { + this.CallJoinGroupDialog(); + } + + GUI.enabled = enabled && FB.IsLoggedIn; + if (this.Button("Get All App Managed Groups")) + { + this.CallFbGetAllOwnedGroups(); + } + + if (this.Button("Get Gamer Groups Logged in User Belongs to")) + { + this.CallFbGetUserGroups(); + } + + if (this.Button("Make Group Post As User")) + { + this.CallFbPostToGamerGroup(); + } + + GUI.enabled = enabled; + } + + private void GroupCreateCB(IGroupCreateResult result) + { + this.HandleResult(result); + if (result.GroupId != null) + { + this.gamerGroupCurrentGroup = result.GroupId; + } + } + + private void GetAllGroupsCB(IGraphResult result) + { + if (!string.IsNullOrEmpty(result.RawResult)) + { + this.LastResponse = result.RawResult; + var resultDictionary = result.ResultDictionary; + if (resultDictionary.ContainsKey("data")) + { + var dataArray = (List)resultDictionary["data"]; + + if (dataArray.Count > 0) + { + var firstGroup = (Dictionary)dataArray[0]; + this.gamerGroupCurrentGroup = (string)firstGroup["id"]; + } + } + } + + if (!string.IsNullOrEmpty(result.Error)) + { + this.LastResponse = result.Error; + } + } + + private void CallFbGetAllOwnedGroups() + { + FB.API(FB.AppId + "/groups", HttpMethod.GET, this.GetAllGroupsCB); + } + + private void CallFbGetUserGroups() + { + FB.API("/me/groups?parent=" + FB.AppId, HttpMethod.GET, this.HandleResult); + } + + private void CallCreateGroupDialog() + { + FB.GameGroupCreate( + this.gamerGroupName, + this.gamerGroupDesc, + this.gamerGroupPrivacy, + this.GroupCreateCB); + } + + private void CallJoinGroupDialog() + { + FB.GameGroupJoin( + this.gamerGroupCurrentGroup, + this.HandleResult); + } + + private void CallFbPostToGamerGroup() + { + Dictionary dict = new Dictionary(); + dict["message"] = "herp derp a post"; + + FB.API( + this.gamerGroupCurrentGroup + "/feed", + HttpMethod.POST, + this.HandleResult, + dict); + } + } +} diff --git a/Facebook.Unity/Assets/Examples/Scripts/SubMenus/GameGroups.cs.meta b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/GameGroups.cs.meta new file mode 100644 index 000000000..c67c819d3 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/GameGroups.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: db1bc390317cb4b799efac28a460ea64 +timeCreated: 1435018470 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Examples/Scripts/SubMenus/GraphRequest.cs b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/GraphRequest.cs new file mode 100644 index 000000000..323e28620 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/GraphRequest.cs @@ -0,0 +1,75 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Example +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using UnityEngine; + + internal class GraphRequest : MenuBase + { + private string apiQuery = string.Empty; + + protected override void GetGui() + { + bool enabled = GUI.enabled; + GUI.enabled = enabled && FB.IsLoggedIn; + if (this.Button("Basic Request - Me")) + { + FB.API("/me", HttpMethod.GET, this.HandleResult); + } + + if (this.Button("Take and Upload screenshot")) + { + this.StartCoroutine(this.TakeScreenshot()); + } + + this.LabelAndTextField("Request", ref this.apiQuery); + if (this.Button("Custom Request")) + { + FB.API(this.apiQuery, HttpMethod.GET, this.HandleResult); + } + + GUI.enabled = enabled; + } + + private IEnumerator TakeScreenshot() + { + yield return new WaitForEndOfFrame(); + + var width = Screen.width; + var height = Screen.height; + var tex = new Texture2D(width, height, TextureFormat.RGB24, false); + + // Read screen contents into the texture + tex.ReadPixels(new Rect(0, 0, width, height), 0, 0); + tex.Apply(); + byte[] screenshot = tex.EncodeToPNG(); + + var wwwForm = new WWWForm(); + wwwForm.AddBinaryData("image", screenshot, "InteractiveConsole.png"); + wwwForm.AddField("message", "herp derp. I did a thing! Did I do this right?"); + FB.API("me/photos", HttpMethod.POST, this.HandleResult, wwwForm); + } + } +} diff --git a/Facebook.Unity/Assets/Examples/Scripts/SubMenus/GraphRequest.cs.meta b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/GraphRequest.cs.meta new file mode 100644 index 000000000..3cc8f3f84 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/GraphRequest.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 23c3cb06c2209474e9a8441e2712d5d2 +timeCreated: 1435018470 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Examples/Scripts/SubMenus/MainMenu.cs b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/MainMenu.cs new file mode 100644 index 000000000..6c05781e5 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/MainMenu.cs @@ -0,0 +1,154 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Example +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using UnityEngine; + + internal sealed class MainMenu : MenuBase + { + protected override bool ShowBackButton() + { + return false; + } + + protected override void GetGui() + { + bool enabled = GUI.enabled; + if (this.Button("FB.Init")) + { + FB.Init(this.OnInitComplete, this.OnHideUnity); + this.Status = "FB.Init() called with " + FB.AppId; + } + + GUILayout.BeginHorizontal(); + + GUI.enabled = enabled && FB.IsInitialized; + if (this.Button("Login")) + { + this.CallFBLogin(); + this.Status = "Login called"; + } + + GUI.enabled = FB.IsLoggedIn; + if (this.Button("Get publish_actions")) + { + this.CallFBLoginForPublish(); + this.Status = "Login (for publish_actions) called"; + } + + #if UNITY_IOS || UNITY_ANDROID || UNITY_WP8 || UNITY_EDITOR + if (Button("Logout")) + { + CallFBLogout(); + this.Status = "Logout called"; + } + #endif + GUILayout.EndHorizontal(); + + GUI.enabled = enabled && FB.IsInitialized; + if (this.Button("Share Dialog")) + { + this.SwitchMenu(typeof(DialogShare)); + } + + bool savedEnabled = GUI.enabled; + GUI.enabled = enabled && + AccessToken.CurrentAccessToken != null && + AccessToken.CurrentAccessToken.Permissions.Contains("publish_actions"); + if (this.Button("Game Groups")) + { + this.SwitchMenu(typeof(GameGroups)); + } + + GUI.enabled = savedEnabled; + + if (this.Button("App Requests")) + { + this.SwitchMenu(typeof(AppRequests)); + } + + if (this.Button("Graph Request")) + { + this.SwitchMenu(typeof(GraphRequest)); + } + + if (Constants.IsWeb && this.Button("Pay")) + { + this.SwitchMenu(typeof(Pay)); + } + + if (this.Button("App Events")) + { + this.SwitchMenu(typeof(AppEvents)); + } + + if (this.Button("App Links")) + { + this.SwitchMenu(typeof(AppLinks)); + } + + if (Constants.IsMobile && this.Button("App Invites")) + { + this.SwitchMenu(typeof(AppInvites)); + } + + GUI.enabled = enabled; + } + + private void CallFBLogin() + { + FB.LogInWithReadPermissions(new List() { "public_profile", "email", "user_friends" }, this.HandleResult); + } + + private void CallFBLoginForPublish() + { + // It is generally good behavior to split asking for read and publish + // permissions rather than ask for them all at once. + // + // In your own game, consider postponing this call until the moment + // you actually need it. + FB.LogInWithPublishPermissions(new List() { "publish_actions" }, this.HandleResult); + } + + private void CallFBLogout() + { + FB.LogOut(); + } + + private void OnInitComplete() + { + this.Status = "Success - Check logk for details"; + this.LastResponse = "Success Response: OnInitComplete Called\n"; + LogView.AddLog("OnInitComplete Called"); + } + + private void OnHideUnity(bool isGameShown) + { + this.Status = "Success - Check logk for details"; + this.LastResponse = string.Format("Success Response: OnHideUnity Called {0}\n", isGameShown); + LogView.AddLog("Is game shown: " + isGameShown); + } + } +} diff --git a/Facebook.Unity/Assets/Examples/Scripts/SubMenus/MainMenu.cs.meta b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/MainMenu.cs.meta new file mode 100644 index 000000000..06e7c47ad --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/MainMenu.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 922e3ad8d88a146b3b392cd8c84edd6a +timeCreated: 1435018470 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Examples/Scripts/SubMenus/Pay.cs b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/Pay.cs new file mode 100644 index 000000000..f7a26487b --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/Pay.cs @@ -0,0 +1,47 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Example +{ + using System; + using System.Collections; + using UnityEngine; + + internal class Pay : MenuBase + { + private string payProduct = string.Empty; + + protected override void GetGui() + { + this.LabelAndTextField("Product: ", ref this.payProduct); + if (this.Button("Call Pay")) + { + this.CallFBPay(); + } + + GUILayout.Space(10); + } + + private void CallFBPay() + { + FB.Canvas.Pay(this.payProduct, callback: this.HandleResult); + } + } +} diff --git a/Facebook.Unity/Assets/Examples/Scripts/SubMenus/Pay.cs.meta b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/Pay.cs.meta new file mode 100644 index 000000000..de5ac0a95 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Scripts/SubMenus/Pay.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7f08c9721703046ec883e57562184726 +timeCreated: 1435018470 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Examples/Textures.meta b/Facebook.Unity/Assets/Examples/Textures.meta new file mode 100644 index 000000000..6d5aee262 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Textures.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: d9bb81c4122cb47d3a608178bcb9e42c +folderAsset: yes +DefaultImporter: + userData: diff --git a/Facebook.Unity/Assets/Examples/Textures/White.psd b/Facebook.Unity/Assets/Examples/Textures/White.psd new file mode 100644 index 0000000000000000000000000000000000000000..4cc7f9c8cfe9e3de4429c16afd6c32e423b297ef GIT binary patch literal 23542 zcmeHP33wAl`=8z1X?mn-OMwF0o2yOIHa$Y`^n`|%wv0Gelwf1OAY=%^!YzNPqxp_zSq1n`+MKnot>wd z%)+V~fC0zBfER)~xd74d7@eG1SgvHoQ%nd|dKHu|4hae>vh!NaDs>ZSBkD=5&X^PP z)0^+c5IRjx%m|rMqBJYWMqSw?3t2O1XsvoulR8Tilb6fSZk4wh%m&h?B3cc4qgCFT z6Qk0Y>Pb1IkysoTErUR_k;Yz}fcF^x8xSuPg0w6r9*q$ZmzTCp@M zD+{?vNlAhhN!E!*o2oU*XpMC^arr4Ct!j(TY}1*H1oEq@H`#4DF)^qi_u;%RgW27X z(V9%%W3t+05Vxw#VrjBO?Dh;RW_((H;%w%B9(clR1bS*dh)yvrmq z7{pyApVd~}4D-^N=Uvvc)=o5&;%d@rvRl+-aWllhlkCovR4V1=MypL_RFmaJxv)FQ zI-N#dB*{oiD=x`Y$Wo-~nNm1((iDa15?Mx(Oj;nzDxxy0bJfl{0d++twH-n4bgO}G z(-rBNMVX4U!VKSTy{g{fw$h@5k0O=c%LeuO|Kh$27k4yMrnAC&(`lPVx2w)|K&3e#|*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+CZF&6J^*aupzHmbba2)oQN%e`tX33~7L`y@Num=-jM68sl^TJRM z_EaBhPmQZTYne7*Q4_AVrd^3=qYiKqWP6XpPORysDIT6~BfoZc;m>=J=;=bo=Rm-q z+7yC3aIJQJd3?XP`Q?=zN4@CJsO*ZSz#R@t3h7`_05re^>ftgF0jIEykha0oN>OHL zCc29S0TiGHIF`z&7Gh8fSh7+H`a^;XI9MpP(=QAnl=q+(lu?lDv7T;vJl5A~gF_oB zwP=Lavn*H&MWZn>_i-JyScK}Xh38SgzdZ#2xbo+``rN=4pj~O@5}70j;QoFyW*;4e|n=biIV;szrUElvq2hmBF?xuBAET1e91yEUvcEGMmeLg~I67 zM|5A+CTf9@OI3pfg~2L{i!wA=;7S4&d#`(T-8&#CD_Ed9B}!`(B;iU!M~73M0xj`> M_utu$fA`;i0c+?@r~m)} literal 0 HcmV?d00001 diff --git a/Facebook.Unity/Assets/Examples/Textures/White.psd.meta b/Facebook.Unity/Assets/Examples/Textures/White.psd.meta new file mode 100644 index 000000000..6a0acbd64 --- /dev/null +++ b/Facebook.Unity/Assets/Examples/Textures/White.psd.meta @@ -0,0 +1,46 @@ +fileFormatVersion: 2 +guid: 6f2bd1fb3a7ec4616b4311f171db577d +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Facebook.Unity/Assets/Facebook.meta b/Facebook.Unity/Assets/Facebook.meta new file mode 100644 index 000000000..5df351ed1 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: aa6eb934733ff44dba4463c29c86ab05 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Facebook.Unity/Assets/Facebook/Debug.meta b/Facebook.Unity/Assets/Facebook/Debug.meta new file mode 100644 index 000000000..72f3df826 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Debug.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 46f3dc143cf1f4cad9aab07a4fc1c7ae +folderAsset: yes +timeCreated: 1432149250 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Editor.meta b/Facebook.Unity/Assets/Facebook/Editor.meta new file mode 100644 index 000000000..3fe3f5ac5 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: f781be5bc0c51ee47aaa89239962614d +folderAsset: yes +DefaultImporter: + userData: diff --git a/Facebook.Unity/Assets/Facebook/Editor/FacebookBuild.cs b/Facebook.Unity/Assets/Facebook/Editor/FacebookBuild.cs new file mode 100644 index 000000000..037bee98e --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/FacebookBuild.cs @@ -0,0 +1,85 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Editor +{ + using System; + using System.Collections.Generic; + using System.IO; + using UnityEditor; + using UnityEngine; + + public class FacebookBuild + { + private const string FacebookPath = "Assets/Facebook/"; + private const string ExamplesPath = "Assets/Examples/"; + private const string PluginsPath = "Assets/Plugins/"; + + public enum Target + { + DEBUG, + RELEASE + } + + // Exporting the *.unityPackage for Asset store + public static void ExportPackage() + { + Debug.Log("Exporting Facebook Unity Package..."); + + var path = "FacebookSDK.unitypackage"; + + try + { + if (!File.Exists(Path.Combine(Application.dataPath, "Temp"))) + { + AssetDatabase.CreateFolder("Assets", "Temp"); + } + + AssetDatabase.MoveAsset(FacebookPath + "Resources/FacebookSettings.asset", "Assets/Temp/FacebookSettings.asset"); + AssetDatabase.DeleteAsset(PluginsPath + "Android/AndroidManifest.xml"); + AssetDatabase.DeleteAsset(PluginsPath + "Android/AndroidManifest.xml.meta"); + + string[] facebookFiles = (string[])Directory.GetFiles(FacebookPath, "*.*", SearchOption.AllDirectories); + string[] exampleFiles = (string[])Directory.GetFiles(ExamplesPath, "*.*", SearchOption.AllDirectories); + string[] pluginsFiles = (string[])Directory.GetFiles(PluginsPath, "*.*", SearchOption.AllDirectories); + string[] files = new string[facebookFiles.Length + exampleFiles.Length + pluginsFiles.Length]; + facebookFiles.CopyTo(files, 0); + exampleFiles.CopyTo(files, facebookFiles.Length); + pluginsFiles.CopyTo(files, facebookFiles.Length + exampleFiles.Length); + + AssetDatabase.ExportPackage( + files, + path, + ExportPackageOptions.IncludeDependencies | ExportPackageOptions.Recurse); + } + finally + { + // Move files back no matter what + AssetDatabase.MoveAsset("Assets/Temp/FacebookSettings.asset", FacebookPath + "Resources/FacebookSettings.asset"); + AssetDatabase.DeleteAsset("Assets/Temp"); + + // regenerate the manifest + UnityEditor.FacebookEditor.ManifestMod.GenerateManifest(); + } + + Debug.Log("Finished exporting!"); + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Editor/FacebookBuild.cs.meta b/Facebook.Unity/Assets/Facebook/Editor/FacebookBuild.cs.meta new file mode 100644 index 000000000..81bb176bf --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/FacebookBuild.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e949c7ce787bb49bcbc2386c1ce7995c +timeCreated: 1432146685 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Editor/FacebookPostprocess.cs b/Facebook.Unity/Assets/Facebook/Editor/FacebookPostprocess.cs new file mode 100644 index 000000000..5dbe2f140 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/FacebookPostprocess.cs @@ -0,0 +1,92 @@ +/** + * 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. + */ + +namespace UnityEditor.FacebookEditor +{ + using System; + using System.IO; + using Facebook.Unity; + using UnityEditor; + using UnityEditor.Callbacks; + using UnityEditor.FacebookEditor; + using UnityEngine; + + public static class XCodePostProcess + { + [PostProcessBuild(100)] + public static void OnPostProcessBuild(BuildTarget target, string path) + { + // If integrating with facebook on any platform, throw a warning if the app id is invalid + if (!Facebook.Unity.FacebookSettings.IsValidAppId) + { + Debug.LogWarning("You didn't specify a Facebook app ID. Please add one using the Facebook menu in the main Unity editor."); + } + + // Unity renamed build target from iPhone to iOS in Unity 5, this keeps both versions happy + if (target.ToString() == "iOS" || target.ToString() == "iPhone") + { + UpdatePlist(path); + FixupFiles.FixSimulator(path); + FixupFiles.AddVersionDefine(path); + FixupFiles.FixColdStart(path); + } + + if (target == BuildTarget.Android) + { + // The default Bundle Identifier for Unity does magical things that causes bad stuff to happen + if (PlayerSettings.bundleIdentifier == "com.Company.ProductName") + { + Debug.LogError("The default Unity Bundle Identifier (com.Company.ProductName) will not work correctly."); + } + + if (!FacebookAndroidUtil.SetupProperly) + { + Debug.LogError("Your Android setup is not correct. See Settings in Facebook menu."); + } + + if (!ManifestMod.CheckManifest()) + { + // If something is wrong with the Android Manifest, try to regenerate it to fix it for the next build. + ManifestMod.GenerateManifest(); + } + } + } + + public static void UpdatePlist(string path) + { + const string FileName = "Info.plist"; + string appId = FacebookSettings.AppId; + string fullPath = Path.Combine(path, FileName); + + if (string.IsNullOrEmpty(appId) || appId.Equals("0")) + { + Debug.LogError("You didn't specify a Facebook app ID. Please add one using the Facebook menu in the main Unity editor."); + return; + } + + var facebookParser = new PListParser(fullPath); + facebookParser.UpdateFBSettings( + appId, + FacebookSettings.IosURLSuffix, + FacebookSettings.AppLinkSchemes[FacebookSettings.SelectedAppIndex].Schemes); + facebookParser.WriteToFile(); + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Editor/FacebookPostprocess.cs.meta b/Facebook.Unity/Assets/Facebook/Editor/FacebookPostprocess.cs.meta new file mode 100644 index 000000000..6aa9971f6 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/FacebookPostprocess.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3216b4e3e4b254633aba22bc434edb28 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Facebook.Unity/Assets/Facebook/Editor/FacebookSettingsEditor.cs b/Facebook.Unity/Assets/Facebook/Editor/FacebookSettingsEditor.cs new file mode 100644 index 000000000..40955f08e --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/FacebookSettingsEditor.cs @@ -0,0 +1,297 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Editor +{ + using System.Collections; + using System.Collections.Generic; + using System.Reflection; + using UnityEditor; + using UnityEditor.FacebookEditor; + using UnityEngine; + + [CustomEditor(typeof(FacebookSettings))] + public class FacebookSettingsEditor : UnityEditor.Editor + { + private bool showFacebookInitSettings = false; + private bool showAndroidUtils = EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android; + private bool showIOSSettings = EditorUserBuildSettings.activeBuildTarget.ToString() == "iOS"; + private bool showAppLinksSettings = false; + private bool showAboutSection = false; + + private GUIContent appNameLabel = new GUIContent("App Name [?]:", "For your own use and organization.\n(ex. 'dev', 'qa', 'prod')"); + private GUIContent appIdLabel = new GUIContent("App Id [?]:", "Facebook App Ids can be found at https://developers.facebook.com/apps"); + + private GUIContent urlSuffixLabel = new GUIContent("URL Scheme Suffix [?]", "Use this to share Facebook APP ID's across multiple iOS apps. https://developers.facebook.com/docs/ios/share-appid-across-multiple-apps-ios-sdk/"); + + private GUIContent cookieLabel = new GUIContent("Cookie [?]", "Sets a cookie which your server-side code can use to validate a user's Facebook session"); + private GUIContent loggingLabel = new GUIContent("Logging [?]", "(Web Player only) If true, outputs a verbose log to the Javascript console to facilitate debugging."); + private GUIContent statusLabel = new GUIContent("Status [?]", "If 'true', attempts to initialize the Facebook object with valid session data."); + private GUIContent xfbmlLabel = new GUIContent("Xfbml [?]", "(Web Player only If true) Facebook will immediately parse any XFBML elements on the Facebook Canvas page hosting the app"); + private GUIContent frictionlessLabel = new GUIContent("Frictionless Requests [?]", "Use frictionless app requests, as described in their own documentation."); + + private GUIContent packageNameLabel = new GUIContent("Package Name [?]", "aka: the bundle identifier"); + private GUIContent classNameLabel = new GUIContent("Class Name [?]", "aka: the activity name"); + private GUIContent debugAndroidKeyLabel = new GUIContent("Debug Android Key Hash [?]", "Copy this key to the Facebook Settings in order to test a Facebook Android app"); + + private GUIContent sdkVersion = new GUIContent("SDK Version [?]", "This Unity Facebook SDK version. If you have problems or compliments please include this so we know exactly what version to look out for."); + + public override void OnInspectorGUI() + { + EditorGUILayout.Separator(); + this.AppIdGUI(); + EditorGUILayout.Separator(); + this.FBParamsInitGUI(); + EditorGUILayout.Separator(); + this.AndroidUtilGUI(); + EditorGUILayout.Separator(); + this.IOSUtilGUI(); + EditorGUILayout.Separator(); + this.AppLinksUtilGUI(); + EditorGUILayout.Separator(); + this.AboutGUI(); + EditorGUILayout.Separator(); + this.BuildGUI(); + } + + private void AppIdGUI() + { + EditorGUILayout.LabelField("Add the Facebook App Id(s) associated with this game"); + if (FacebookSettings.AppIds.Count == 0 || FacebookSettings.AppId == "0") + { + EditorGUILayout.HelpBox("Invalid App Id", MessageType.Error); + } + + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField(this.appNameLabel); + EditorGUILayout.LabelField(this.appIdLabel); + EditorGUILayout.EndHorizontal(); + for (int i = 0; i < FacebookSettings.AppIds.Count; ++i) + { + EditorGUILayout.BeginHorizontal(); + FacebookSettings.AppLabels[i] = EditorGUILayout.TextField(FacebookSettings.AppLabels[i]); + GUI.changed = false; + FacebookSettings.AppIds[i] = EditorGUILayout.TextField(FacebookSettings.AppIds[i]); + if (GUI.changed) + { + FacebookSettings.SettingsChanged(); + ManifestMod.GenerateManifest(); + } + + EditorGUILayout.EndHorizontal(); + } + + EditorGUILayout.BeginHorizontal(); + if (GUILayout.Button("Add Another App Id")) + { + FacebookSettings.AppLabels.Add("New App"); + FacebookSettings.AppIds.Add("0"); + FacebookSettings.AppLinkSchemes.Add(new FacebookSettings.UrlSchemes()); + FacebookSettings.SettingsChanged(); + } + + if (FacebookSettings.AppLabels.Count > 1) + { + if (GUILayout.Button("Remove Last App Id")) + { + FacebookSettings.AppLabels.Pop(); + FacebookSettings.AppIds.Pop(); + FacebookSettings.AppLinkSchemes.Pop(); + FacebookSettings.SettingsChanged(); + } + } + + EditorGUILayout.EndHorizontal(); + EditorGUILayout.Space(); + if (FacebookSettings.AppIds.Count > 1) + { + EditorGUILayout.HelpBox("2) Select Facebook App Id to be compiled with this game", MessageType.None); + GUI.changed = false; + FacebookSettings.SelectedAppIndex = EditorGUILayout.Popup( + "Selected App Id", + FacebookSettings.SelectedAppIndex, + FacebookSettings.AppIds.ToArray()); + if (GUI.changed) + { + ManifestMod.GenerateManifest(); + } + + EditorGUILayout.Space(); + } + else + { + FacebookSettings.SelectedAppIndex = 0; + } + } + + private void FBParamsInitGUI() + { + this.showFacebookInitSettings = EditorGUILayout.Foldout(this.showFacebookInitSettings, "FB.Init() Parameters"); + if (this.showFacebookInitSettings) + { + FacebookSettings.Cookie = EditorGUILayout.Toggle(this.cookieLabel, FacebookSettings.Cookie); + FacebookSettings.Logging = EditorGUILayout.Toggle(this.loggingLabel, FacebookSettings.Logging); + FacebookSettings.Status = EditorGUILayout.Toggle(this.statusLabel, FacebookSettings.Status); + FacebookSettings.Xfbml = EditorGUILayout.Toggle(this.xfbmlLabel, FacebookSettings.Xfbml); + FacebookSettings.FrictionlessRequests = EditorGUILayout.Toggle(this.frictionlessLabel, FacebookSettings.FrictionlessRequests); + } + + EditorGUILayout.Space(); + } + + private void IOSUtilGUI() + { + this.showIOSSettings = EditorGUILayout.Foldout(this.showIOSSettings, "iOS Build Settings"); + if (this.showIOSSettings) + { + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField(this.urlSuffixLabel, GUILayout.Width(135), GUILayout.Height(16)); + FacebookSettings.IosURLSuffix = EditorGUILayout.TextField(FacebookSettings.IosURLSuffix); + EditorGUILayout.EndHorizontal(); + } + + EditorGUILayout.Space(); + } + + private void AndroidUtilGUI() + { + this.showAndroidUtils = EditorGUILayout.Foldout(this.showAndroidUtils, "Android Build Facebook Settings"); + if (this.showAndroidUtils) + { + if (!FacebookAndroidUtil.SetupProperly) + { + var msg = "Your Android setup is not right. Check the documentation."; + switch (FacebookAndroidUtil.SetupError) + { + case FacebookAndroidUtil.ErrorNoSDK: + msg = "You don't have the Android SDK setup! Go to " + (Application.platform == RuntimePlatform.OSXEditor ? "Unity" : "Edit") + "->Preferences... and set your Android SDK Location under External Tools"; + break; + case FacebookAndroidUtil.ErrorNoKeystore: + msg = "Your android debug keystore file is missing! You can create new one by creating and building empty Android project in Ecplise."; + break; + case FacebookAndroidUtil.ErrorNoKeytool: + msg = "Keytool not found. Make sure that Java is installed, and that Java tools are in your path."; + break; + case FacebookAndroidUtil.ErrorNoOpenSSL: + msg = "OpenSSL not found. Make sure that OpenSSL is installed, and that it is in your path."; + break; + case FacebookAndroidUtil.ErrorKeytoolError: + msg = "Unkown error while getting Debug Android Key Hash."; + break; + } + + EditorGUILayout.HelpBox(msg, MessageType.Warning); + } + + EditorGUILayout.LabelField( + "Copy and Paste these into your \"Native Android App\" Settings on developers.facebook.com/apps"); + this.SelectableLabelField(this.packageNameLabel, PlayerSettings.bundleIdentifier); + this.SelectableLabelField(this.classNameLabel, ManifestMod.DeepLinkingActivityName); + this.SelectableLabelField(this.debugAndroidKeyLabel, FacebookAndroidUtil.DebugKeyHash); + if (GUILayout.Button("Regenerate Android Manifest")) + { + ManifestMod.GenerateManifest(); + } + } + + EditorGUILayout.Space(); + } + + private void AppLinksUtilGUI() + { + this.showAppLinksSettings = EditorGUILayout.Foldout(this.showAppLinksSettings, "App Links Settings"); + if (this.showAppLinksSettings) + { + for (int i = 0; i < FacebookSettings.AppLinkSchemes.Count; ++i) + { + EditorGUILayout.LabelField(string.Format("App Link Schemes for '{0}'", FacebookSettings.AppLabels[i])); + List currentAppLinkSchemes = FacebookSettings.AppLinkSchemes[i].Schemes; + for (int j = 0; j < currentAppLinkSchemes.Count; ++j) + { + GUI.changed = false; + string scheme = EditorGUILayout.TextField(currentAppLinkSchemes[j]); + if (scheme != currentAppLinkSchemes[j]) + { + currentAppLinkSchemes[j] = scheme; + FacebookSettings.SettingsChanged(); + } + + if (GUI.changed) + { + ManifestMod.GenerateManifest(); + } + } + + EditorGUILayout.BeginHorizontal(); + if (GUILayout.Button("Add a Scheme")) + { + FacebookSettings.AppLinkSchemes[i].Schemes.Add(string.Empty); + FacebookSettings.SettingsChanged(); + } + + if (currentAppLinkSchemes.Count > 0) + { + if (GUILayout.Button("Remove Last Scheme")) + { + FacebookSettings.AppLinkSchemes[i].Schemes.Pop(); + } + } + + EditorGUILayout.EndHorizontal(); + } + } + } + + private void AboutGUI() + { + this.showAboutSection = EditorGUILayout.Foldout(this.showAboutSection, "About the Facebook SDK"); + if (this.showAboutSection) + { + this.SelectableLabelField(this.sdkVersion, FacebookSdkVersion.Build); + EditorGUILayout.Space(); + } + } + + private void SelectableLabelField(GUIContent label, string value) + { + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField(label, GUILayout.Width(180), GUILayout.Height(16)); + EditorGUILayout.SelectableLabel(value, GUILayout.Height(16)); + EditorGUILayout.EndHorizontal(); + } + + private void BuildGUI() + { + if (GUILayout.Button("Build SDK Package")) + { + try + { + FacebookBuild.ExportPackage(); + } + catch (System.Exception e) + { + EditorUtility.DisplayDialog("Error Exporting unityPackage", e.Message, "Okay"); + } + + EditorUtility.DisplayDialog("Finished Exporting unityPackage", "Exported to CUI/SDKPackage", "Okay"); + } + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Editor/FacebookSettingsEditor.cs.meta b/Facebook.Unity/Assets/Facebook/Editor/FacebookSettingsEditor.cs.meta new file mode 100644 index 000000000..30bdee1d7 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/FacebookSettingsEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b0e3377bc775f8a448581e00451b26a2 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Facebook.Unity/Assets/Facebook/Editor/Utility.cs b/Facebook.Unity/Assets/Facebook/Editor/Utility.cs new file mode 100644 index 000000000..ac770900e --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/Utility.cs @@ -0,0 +1,58 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Editor +{ + using System; + using System.Collections.Generic; + using System.Linq; + + public static class Utility + { + public static T Pop(this IList list) + { + if (!list.Any()) + { + throw new InvalidOperationException("Attempting to pop item on empty list."); + } + + int index = list.Count - 1; + T value = list[index]; + list.RemoveAt(index); + return value; + } + + public static bool TryGetValue( + this IDictionary dictionary, + string key, + out T value) + { + object resultObj; + if (dictionary.TryGetValue(key, out resultObj) && resultObj is T) + { + value = (T)resultObj; + return true; + } + + value = default(T); + return false; + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Editor/Utility.cs.meta b/Facebook.Unity/Assets/Facebook/Editor/Utility.cs.meta new file mode 100644 index 000000000..d47801cea --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/Utility.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 500d56b96bf1645318c5a578abbcd624 +timeCreated: 1441314482 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Editor/android.meta b/Facebook.Unity/Assets/Facebook/Editor/android.meta new file mode 100644 index 000000000..57568cb1c --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/android.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 421c8bec6d2cc41c887bdd0ecc035702 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Facebook.Unity/Assets/Facebook/Editor/android/FacebookAndroidUtil.cs b/Facebook.Unity/Assets/Facebook/Editor/android/FacebookAndroidUtil.cs new file mode 100644 index 000000000..7cebbe5d2 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/android/FacebookAndroidUtil.cs @@ -0,0 +1,176 @@ +/** + * 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. + */ + +namespace UnityEditor.FacebookEditor +{ + using System; + using System.Collections; + using System.Diagnostics; + using System.Text; + using UnityEngine; + + public class FacebookAndroidUtil + { + public const string ErrorNoSDK = "no_android_sdk"; + public const string ErrorNoKeystore = "no_android_keystore"; + public const string ErrorNoKeytool = "no_java_keytool"; + public const string ErrorNoOpenSSL = "no_openssl"; + public const string ErrorKeytoolError = "java_keytool_error"; + + private static string debugKeyHash; + private static string setupError; + + public static bool SetupProperly + { + get + { + return DebugKeyHash != null; + } + } + + public static string DebugKeyHash + { + get + { + if (debugKeyHash == null) + { + if (!HasAndroidSDK()) + { + setupError = ErrorNoSDK; + return null; + } + + if (!HasAndroidKeystoreFile()) + { + setupError = ErrorNoKeystore; + return null; + } + + if (!DoesCommandExist("echo \"xxx\" | openssl base64")) + { + setupError = ErrorNoOpenSSL; + return null; + } + + if (!DoesCommandExist("keytool")) + { + setupError = ErrorNoKeytool; + return null; + } + + debugKeyHash = GetKeyHash("androiddebugkey", DebugKeyStorePath, "android"); + } + + return debugKeyHash; + } + } + + public static string SetupError + { + get + { + return setupError; + } + } + + private static string DebugKeyStorePath + { + get + { + return (Application.platform == RuntimePlatform.WindowsEditor) ? + System.Environment.GetEnvironmentVariable("HOMEDRIVE") + System.Environment.GetEnvironmentVariable("HOMEPATH") + @"\.android\debug.keystore" : + System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + @"/.android/debug.keystore"; + } + } + + public static bool HasAndroidSDK() + { + return EditorPrefs.HasKey("AndroidSdkRoot") && System.IO.Directory.Exists(EditorPrefs.GetString("AndroidSdkRoot")); + } + + public static bool HasAndroidKeystoreFile() + { + return System.IO.File.Exists(DebugKeyStorePath); + } + + private static string GetKeyHash(string alias, string keyStore, string password) + { + var proc = new Process(); + var arguments = @"""keytool -storepass {0} -keypass {1} -exportcert -alias {2} -keystore {3} | openssl sha1 -binary | openssl base64"""; + if (Application.platform == RuntimePlatform.WindowsEditor) + { + proc.StartInfo.FileName = "cmd"; + arguments = @"/C " + arguments; + } + else + { + proc.StartInfo.FileName = "bash"; + arguments = @"-c " + arguments; + } + + proc.StartInfo.Arguments = string.Format(arguments, password, password, alias, keyStore); + proc.StartInfo.UseShellExecute = false; + proc.StartInfo.CreateNoWindow = true; + proc.StartInfo.RedirectStandardOutput = true; + proc.Start(); + var keyHash = new StringBuilder(); + while (!proc.HasExited) + { + keyHash.Append(proc.StandardOutput.ReadToEnd()); + } + + switch (proc.ExitCode) + { + case 255: setupError = ErrorKeytoolError; + return null; + } + + return keyHash.ToString().TrimEnd('\n'); + } + + private static bool DoesCommandExist(string command) + { + var proc = new Process(); + if (Application.platform == RuntimePlatform.WindowsEditor) + { + proc.StartInfo.FileName = "cmd"; + proc.StartInfo.Arguments = @"/C" + command; + } + else + { + proc.StartInfo.FileName = "bash"; + proc.StartInfo.Arguments = @"-c " + command; + } + + proc.StartInfo.UseShellExecute = false; + proc.StartInfo.CreateNoWindow = true; + proc.Start(); + proc.WaitForExit(); + if (Application.platform == RuntimePlatform.WindowsEditor) + { + return proc.ExitCode == 0; + } + else + { + return proc.ExitCode != 127; + } + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Editor/android/FacebookAndroidUtil.cs.meta b/Facebook.Unity/Assets/Facebook/Editor/android/FacebookAndroidUtil.cs.meta new file mode 100644 index 000000000..cb73ec9b5 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/android/FacebookAndroidUtil.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9b6cf78768917b048aff739cf91300c7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Facebook.Unity/Assets/Facebook/Editor/android/ManifestMod.cs b/Facebook.Unity/Assets/Facebook/Editor/android/ManifestMod.cs new file mode 100644 index 000000000..8344ca411 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/android/ManifestMod.cs @@ -0,0 +1,354 @@ +/** + * 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. + */ + +namespace UnityEditor.FacebookEditor +{ + using System.Collections.Generic; + using System.Globalization; + using System.IO; + using System.Linq; + using System.Text; + using System.Xml; + using Facebook.Unity; + using UnityEditor; + using UnityEngine; + + public class ManifestMod + { + public const string AppLinkActivityName = "com.facebook.unity.FBUnityAppLinkActivity"; + public const string DeepLinkingActivityName = "com.facebook.unity.FBUnityDeepLinkingActivity"; + public const string LoginActivityName = "com.facebook.LoginActivity"; + public const string UnityLoginActivityName = "com.facebook.unity.FBUnityLoginActivity"; + public const string UnityDialogsActivityName = "com.facebook.unity.FBUnityDialogsActivity"; + public const string UnityGameRequestActivityName = "com.facebook.unity.FBUnityGameRequestActivity"; + public const string UnityGameGroupCreateActivityName = "com.facebook.unity.FBUnityCreateGameGroupActivity"; + public const string UnityGameGroupJoinActivityName = "com.facebook.unity.FBUnityJoinGameGroupActivity"; + public const string UnityAppInviteDialogActivityName = "com.facebook.unity.AppInviteDialogActivity"; + public const string ApplicationIdMetaDataName = "com.facebook.sdk.ApplicationId"; + public const string FacebookContentProviderName = "com.facebook.FacebookContentProvider"; + public const string FacebookContentProviderAuthFormat = "com.facebook.app.FacebookContentProvider{0}"; + public const string FacebookActivityName = "com.facebook.FacebookActivity"; + + public static void GenerateManifest() + { + var outputFile = Path.Combine(Application.dataPath, "Plugins/Android/AndroidManifest.xml"); + + // only copy over a fresh copy of the AndroidManifest if one does not exist + if (!File.Exists(outputFile)) + { + var inputFile = Path.Combine( + EditorApplication.applicationContentsPath, + "PlaybackEngines/androidplayer/AndroidManifest.xml"); + if (!File.Exists(inputFile)) + { + // Unity moved this file. Try to get it at its new location + inputFile = Path.Combine( + EditorApplication.applicationContentsPath, + "PlaybackEngines/AndroidPlayer/Apk/AndroidManifest.xml"); + } + + File.Copy(inputFile, outputFile); + } + + UpdateManifest(outputFile); + } + + public static bool CheckManifest() + { + bool result = true; + var outputFile = Path.Combine(Application.dataPath, "Plugins/Android/AndroidManifest.xml"); + if (!File.Exists(outputFile)) + { + Debug.LogError("An android manifest must be generated for the Facebook SDK to work. Go to Facebook->Edit Settings and press \"Regenerate Android Manifest\""); + return false; + } + + XmlDocument doc = new XmlDocument(); + doc.Load(outputFile); + + if (doc == null) + { + Debug.LogError("Couldn't load " + outputFile); + return false; + } + + XmlNode manNode = FindChildNode(doc, "manifest"); + XmlNode dict = FindChildNode(manNode, "application"); + + if (dict == null) + { + Debug.LogError("Error parsing " + outputFile); + return false; + } + + XmlElement loginElement; + if (!ManifestMod.TryFindElementWithAndroidName(dict, UnityLoginActivityName, out loginElement)) + { + Debug.LogError(string.Format("{0} is missing from your android manifest. Go to Facebook->Edit Settings and press \"Regenerate Android Manifest\"", LoginActivityName)); + result = false; + } + + var deprecatedMainActivityName = "com.facebook.unity.FBUnityPlayerActivity"; + XmlElement deprecatedElement; + if (ManifestMod.TryFindElementWithAndroidName(dict, deprecatedMainActivityName, out deprecatedElement)) + { + Debug.LogWarning(string.Format("{0} is deprecated and no longer needed for the Facebook SDK. Feel free to use your own main activity or use the default \"com.unity3d.player.UnityPlayerNativeActivity\"", deprecatedMainActivityName)); + } + + return result; + } + + public static void UpdateManifest(string fullPath) + { + string appId = FacebookSettings.AppId; + + if (!FacebookSettings.IsValidAppId) + { + Debug.LogError("You didn't specify a Facebook app ID. Please add one using the Facebook menu in the main Unity editor."); + return; + } + + XmlDocument doc = new XmlDocument(); + doc.Load(fullPath); + + if (doc == null) + { + Debug.LogError("Couldn't load " + fullPath); + return; + } + + XmlNode manNode = FindChildNode(doc, "manifest"); + XmlNode dict = FindChildNode(manNode, "application"); + + if (dict == null) + { + Debug.LogError("Error parsing " + fullPath); + return; + } + + string ns = dict.GetNamespaceOfPrefix("android"); + + // add the unity login activity + XmlElement unityLoginElement = CreateUnityOverlayElement(doc, ns, UnityLoginActivityName); + ManifestMod.SetOrReplaceXmlElement(dict, unityLoginElement); + + // add the unity dialogs activity + XmlElement unityDialogsElement = CreateUnityOverlayElement(doc, ns, UnityDialogsActivityName); + ManifestMod.SetOrReplaceXmlElement(dict, unityDialogsElement); + + // add the login activity + XmlElement loginElement = CreateLoginElement(doc, ns); + ManifestMod.SetOrReplaceXmlElement(dict, loginElement); + + ManifestMod.AddAppLinkingActivity(doc, dict, ns, FacebookSettings.AppLinkSchemes[FacebookSettings.SelectedAppIndex].Schemes); + + ManifestMod.AddSimpleActivity(doc, dict, ns, DeepLinkingActivityName, true); + ManifestMod.AddSimpleActivity(doc, dict, ns, UnityGameRequestActivityName); + ManifestMod.AddSimpleActivity(doc, dict, ns, UnityGameGroupCreateActivityName); + ManifestMod.AddSimpleActivity(doc, dict, ns, UnityGameGroupJoinActivityName); + ManifestMod.AddSimpleActivity(doc, dict, ns, UnityAppInviteDialogActivityName); + + // add the app id + // + XmlElement appIdElement = doc.CreateElement("meta-data"); + appIdElement.SetAttribute("name", ns, ApplicationIdMetaDataName); + appIdElement.SetAttribute("value", ns, "fb" + appId); + ManifestMod.SetOrReplaceXmlElement(dict, appIdElement); + + // Add the facebook content provider + // + XmlElement contentProviderElement = CreateContentProviderElement(doc, ns, appId); + ManifestMod.SetOrReplaceXmlElement(dict, contentProviderElement); + + // Add the facebook activity + // + XmlElement facebookElement = CreateFacebookElement(doc, ns); + ManifestMod.SetOrReplaceXmlElement(dict, facebookElement); + + // Save the document formatted + XmlWriterSettings settings = new XmlWriterSettings + { + Indent = true, + IndentChars = " ", + NewLineChars = "\r\n", + NewLineHandling = NewLineHandling.Replace + }; + + using (XmlWriter xmlWriter = XmlWriter.Create(fullPath, settings)) + { + doc.Save(xmlWriter); + } + } + + private static XmlNode FindChildNode(XmlNode parent, string name) + { + XmlNode curr = parent.FirstChild; + while (curr != null) + { + if (curr.Name.Equals(name)) + { + return curr; + } + + curr = curr.NextSibling; + } + + return null; + } + + private static void SetOrReplaceXmlElement( + XmlNode parent, + XmlElement newElement) + { + string attrNameValue = newElement.GetAttribute("name"); + string elementType = newElement.Name; + + XmlElement existingElment; + if (TryFindElementWithAndroidName(parent, attrNameValue, out existingElment, elementType)) + { + parent.ReplaceChild(newElement, existingElment); + } + else + { + parent.AppendChild(newElement); + } + } + + private static bool TryFindElementWithAndroidName( + XmlNode parent, + string attrNameValue, + out XmlElement element, + string elementType = "activity") + { + string ns = parent.GetNamespaceOfPrefix("android"); + var curr = parent.FirstChild; + while (curr != null) + { + var currXmlElement = curr as XmlElement; + if (currXmlElement != null && + currXmlElement.Name == elementType && + currXmlElement.GetAttribute("name", ns) == attrNameValue) + { + element = currXmlElement; + return true; + } + + curr = curr.NextSibling; + } + + element = null; + return false; + } + + private static void AddSimpleActivity(XmlDocument doc, XmlNode xmlNode, string ns, string className, bool export = false) + { + XmlElement element = CreateActivityElement(doc, ns, className, export); + ManifestMod.SetOrReplaceXmlElement(xmlNode, element); + } + + private static XmlElement CreateLoginElement(XmlDocument doc, string ns) + { + // + // + XmlElement activityElement = ManifestMod.CreateActivityElement(doc, ns, LoginActivityName); + activityElement.SetAttribute("configChanges", ns, "keyboardHidden|orientation"); + activityElement.SetAttribute("theme", ns, "@android:style/Theme.Translucent.NoTitleBar.Fullscreen"); + return activityElement; + } + + private static XmlElement CreateUnityOverlayElement(XmlDocument doc, string ns, string activityName) + { + // + // + XmlElement activityElement = ManifestMod.CreateActivityElement(doc, ns, activityName); + activityElement.SetAttribute("configChanges", ns, "fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"); + activityElement.SetAttribute("theme", ns, "@android:style/Theme.Translucent.NoTitleBar.Fullscreen"); + return activityElement; + } + + private static XmlElement CreateFacebookElement(XmlDocument doc, string ns) + { + // + // + XmlElement activityElement = ManifestMod.CreateActivityElement(doc, ns, FacebookActivityName); + activityElement.SetAttribute("configChanges", ns, "keyboard|keyboardHidden|screenLayout|screenSize|orientation"); + activityElement.SetAttribute("label", ns, "@string/app_name"); + activityElement.SetAttribute("theme", ns, "@android:style/Theme.Translucent.NoTitleBar"); + return activityElement; + } + + private static XmlElement CreateContentProviderElement(XmlDocument doc, string ns, string appId) + { + XmlElement provierElement = doc.CreateElement("provider"); + provierElement.SetAttribute("name", ns, FacebookContentProviderName); + string authorities = string.Format(CultureInfo.InvariantCulture, FacebookContentProviderAuthFormat, appId); + provierElement.SetAttribute("authorities", ns, authorities); + provierElement.SetAttribute("exported", ns, "true"); + return provierElement; + } + + private static XmlElement CreateActivityElement(XmlDocument doc, string ns, string activityName, bool exported = false) + { + // + // + XmlElement activityElement = doc.CreateElement("activity"); + activityElement.SetAttribute("name", ns, activityName); + if (exported) + { + activityElement.SetAttribute("exported", ns, "true"); + } + + return activityElement; + } + + private static void AddAppLinkingActivity(XmlDocument doc, XmlNode xmlNode, string ns, List schemes) + { + XmlElement element = ManifestMod.CreateActivityElement(doc, ns, AppLinkActivityName, true); + foreach (var scheme in schemes) + { + // We have to create an intent filter for each scheme since an intent filter + // can have only one data element. + XmlElement intentFilter = doc.CreateElement("intent-filter"); + + var action = doc.CreateElement("action"); + action.SetAttribute("name", ns, "android.intent.action.VIEW"); + intentFilter.AppendChild(action); + + var category = doc.CreateElement("category"); + category.SetAttribute("name", ns, "android.intent.category.DEFAULT"); + intentFilter.AppendChild(category); + + XmlElement dataElement = doc.CreateElement("data"); + dataElement.SetAttribute("scheme", ns, scheme); + intentFilter.AppendChild(dataElement); + element.AppendChild(intentFilter); + } + + ManifestMod.SetOrReplaceXmlElement(xmlNode, element); + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Editor/android/ManifestMod.cs.meta b/Facebook.Unity/Assets/Facebook/Editor/android/ManifestMod.cs.meta new file mode 100644 index 000000000..81973a890 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/android/ManifestMod.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 270541881be774590b0c06786fdbdee3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS.meta b/Facebook.Unity/Assets/Facebook/Editor/iOS.meta new file mode 100644 index 000000000..88fb326ba --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 151878557f0654fe4b0270bd5a880df5 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/FBSDK+Internal.h b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBSDK+Internal.h new file mode 100644 index 000000000..a09279131 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBSDK+Internal.h @@ -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 + +@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 \ No newline at end of file diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/FBSDK+Internal.h.meta b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBSDK+Internal.h.meta new file mode 100644 index 000000000..e859956f5 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBSDK+Internal.h.meta @@ -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: diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityInterface.h b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityInterface.h new file mode 100644 index 000000000..7f64828a0 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityInterface.h @@ -0,0 +1,45 @@ +// 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 + +#import "AppDelegateListener.h" +#include "RegisterMonoModules.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 +{ + //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 diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityInterface.h.meta b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityInterface.h.meta new file mode 100644 index 000000000..89d4fb42c --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityInterface.h.meta @@ -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: diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityInterface.mm b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityInterface.mm new file mode 100644 index 000000000..15fbf8452 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityInterface.mm @@ -0,0 +1,588 @@ +// 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. + +#include "FBUnityInterface.h" + +#import +#import +#import +#import + +#include "FBUnitySDKDelegate.h" +#include "FBUnityUtility.h" +#include "FBSDK+Internal.h" + +static FBUnityInterface *_instance = [FBUnityInterface sharedInstance]; + +@interface FBUnityInterface() +@property (nonatomic, copy) NSString *openURLString; +@end + +@implementation FBUnityInterface + +#pragma mark Object Initialization + ++ (FBUnityInterface *)sharedInstance +{ + return _instance; +} + ++ (void)initialize { + if(!_instance) { + _instance = [[FBUnityInterface alloc] init]; + } +} + +- (id)init +{ + if(_instance != nil) { + return _instance; + } + + if ((self = [super init])) { + _instance = self; + self.shareDialogMode = ShareDialogMode::AUTOMATIC; + + UnityRegisterAppDelegateListener(self); + } + return self; +} + +#pragma mark - App (Delegate) Lifecycle + +// didBecomeActive: and onOpenURL: are called by Unity's AppController +// because we implement and registered via UnityRegisterAppDelegateListener(...) above. + +- (void)didFinishLaunching:(NSNotification *)notification +{ + [[FBSDKApplicationDelegate sharedInstance] application:[UIApplication sharedApplication] + didFinishLaunchingWithOptions:notification.userInfo]; +} + +- (void)didBecomeActive:(NSNotification *)notification +{ + [FBSDKAppEvents activateApp]; +} + +- (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 + cookie:(bool)cookie + logging:(bool)logging + status:(bool)status + frictionlessRequests:(bool)frictionlessRequests + urlSuffix:(const char *)urlSuffix +{ + self.useFrictionlessRequests = frictionlessRequests; + + if(appId) { + [FBSDKSettings setAppID:[FBUnityUtility stringFromCString:appId]]; + } + + if(urlSuffix && strlen(urlSuffix) > 0) { + [FBSDKSettings setAppURLSchemeSuffix:[FBUnityUtility stringFromCString:urlSuffix]]; + } + + [FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnInitComplete userData:@{} requestId:0]; + [self tryCompleteLoginWithRequestId: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]; + if (isPublishPermLogin) { + [login logInWithPublishPermissions:permissions + fromViewController:nil + handler:loginHandler]; + } else { + [login logInWithReadPermissions:permissions + fromViewController:nil + handler: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] init]; + dialog.content = content; + dialog.delegate = delegate; + dialog.frictionlessRequestsEnabled = 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)appInviteWithRequestId:(int)requestId + appLinkUrl:(const char *)appLinkUrl + previewImageUrl:(const char *)previewImageUrl +{ + FBSDKAppInviteContent *content = [[FBSDKAppInviteContent alloc] init]; + content.appLinkURL = [NSURL URLWithString:[FBUnityUtility stringFromCString:appLinkUrl]]; + content.appInvitePreviewImageURL = [NSURL URLWithString:[FBUnityUtility stringFromCString:previewImageUrl]]; + FBUnitySDKDelegate *delegate = [FBUnitySDKDelegate instanceWithRequestID:requestId]; + [FBSDKAppInviteDialog showFromViewController:nil + withContent:content + delegate:delegate]; +} + + +- (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]; + } + + NSString *contentTitleStr = [FBUnityUtility stringFromCString:contentTitle]; + if (contentTitleStr) { + linkContent.contentTitle = contentTitleStr; + } + + NSString *contentDescStr = [FBUnityUtility stringFromCString:contentDescription]; + if (contentDescStr) { + linkContent.contentDescription = contentDescStr; + } + + NSString *imageURL = [FBUnityUtility stringFromCString:photoURL]; + if (imageURL) { + linkContent.imageURL = [NSURL URLWithString:imageURL]; + } + + [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]; + } + + NSString *contentTitleStr = [FBUnityUtility stringFromCString:linkName]; + if (contentTitleStr) { + linkContent.contentTitle = contentTitleStr; + } + + NSString *contentDescStr = [FBUnityUtility stringFromCString:linkDescription]; + if (contentDescStr) { + linkContent.contentDescription = contentDescStr; + } + + NSString *imageURL = [FBUnityUtility stringFromCString:picture]; + if (imageURL) { + linkContent.imageURL = [NSURL URLWithString:imageURL]; + } + + 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.feedParameters = feedParameters; + [self shareContentWithRequestId:requestId + shareContent:linkContent + dialogMode:FBSDKShareDialogModeFeedWeb]; +} + +- (void)shareContentWithRequestId:(int)requestId + shareContent:(FBSDKShareLinkContent *)linkContent + dialogMode:(FBSDKShareDialogMode)dialogMode +{ + FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init]; + dialog.shareContent = linkContent; + dialog.mode = dialogMode; + FBUnitySDKDelegate *delegate = [FBUnitySDKDelegate instanceWithRequestID:requestId]; + dialog.delegate = delegate; + + 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; + } +} + +- (void)showJoinAppGroupDialogWithRequestId:(int) requestId + groupId:(const char *) groupId +{ + FBUnitySDKDelegate *delegate = [FBUnitySDKDelegate instanceWithRequestID:requestId]; + [FBSDKAppGroupJoinDialog showWithGroupID:[FBUnityUtility stringFromCString:groupId] delegate:delegate]; +} + +- (void)showCreateAppGroupDialogWithRequestId:(int) requestId + groupName:(const char *) groupName + groupDescription:(const char *) groupDescription + groupPrivacy:(const char *) groupPrivacy +{ + FBSDKAppGroupContent *content = [[FBSDKAppGroupContent alloc] init]; + content.name = [FBUnityUtility stringFromCString:groupName]; + content.groupDescription = [FBUnityUtility stringFromCString:groupDescription]; + + FBSDKAppGroupPrivacy privacy; + NSString *privacyStr = [FBUnityUtility stringFromCString:groupPrivacy]; + if ([privacyStr caseInsensitiveCompare:@"closed"] == NSOrderedSame) { + privacy = FBSDKAppGroupPrivacyClosed; + } else if ([privacyStr caseInsensitiveCompare:@"open"] == NSOrderedSame) { + privacy = FBSDKAppGroupPrivacyOpen; + } else { + NSLog(@"Unexpced privacy type: %@", privacyStr); + privacy = FBSDKAppGroupPrivacyClosed; + } + + content.privacy = privacy; + + FBSDKAppGroupAddDialog *dialog = [[FBSDKAppGroupAddDialog alloc] init]; + dialog.content = content; + dialog.delegate = [FBUnitySDKDelegate instanceWithRequestID:requestId]; + + NSError *error; + if (![dialog validateWithError:&error]) { + [FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnGroupCreateComplete error:error requestId:requestId]; + } + if (![dialog show]) { + [FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnGroupCreateComplete errorMessage:@"Failed to show group create dialog" requestId:requestId]; + } +} + +- (BOOL)tryCompleteLoginWithRequestId:(int) requestId +{ + FBSDKAccessToken *token = [FBSDKAccessToken currentAccessToken]; + if (token) { + NSInteger expiration = token.expirationDate.timeIntervalSince1970; + [FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnLoginComplete + userData:@{ + @"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] + } + requestId:requestId]; + return YES; + } else { + return NO; + } +} + +@end + +#pragma mark - Actual Unity C# interface (extern C) + +extern "C" { + + void IOSInit(const char *_appId, bool _cookie, bool _logging, bool _status, bool _frictionlessRequests, const char *_urlSuffix, const char *_userAgentSuffix) + { + [[FBUnityInterface sharedInstance] configureAppId:_appId + cookie:_cookie + logging:_logging + status:_status + frictionlessRequests:_frictionlessRequests + urlSuffix:_urlSuffix]; + [FBSDKSettings setUserAgentSuffix:[FBUnityUtility stringFromCString:_userAgentSuffix]]; + } + + void IOSLogInWithReadPermissions(int requestId, + const char *scope) + { + [[FBUnityInterface sharedInstance] logInWithReadPermissions:requestId scope:scope]; + } + + void IOSLogInWithPublishPermissions(int requestId, + const char *scope) + { + [[FBUnityInterface sharedInstance] logInWithPublishPermissions:requestId scope:scope]; + } + + void IOSLogOut() + { + [[FBUnityInterface sharedInstance] logOut]; + } + + void IOSSetShareDialogMode(int mode) + { + [FBUnityInterface sharedInstance].shareDialogMode = static_cast(mode); + } + + void IOSAppRequest(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 IOSAppInvite(int requestId, + const char *appLinkUrl, + const char *previewImageUrl) + { + [[FBUnityInterface sharedInstance] appInviteWithRequestId:requestId + appLinkUrl:appLinkUrl + previewImageUrl:previewImageUrl]; + } + + void IOSGetAppLink(int requestId) + { + NSURL *url = [NSURL URLWithString:[FBUnityInterface sharedInstance].openURLString]; + [FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnGetAppLinkComplete + userData:[FBUnityUtility appLinkDataFromUrl:url] + requestId:requestId]; + [FBUnityInterface sharedInstance].openURLString = nil; + } + + void IOSShareLink(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 IOSFeedShare(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 IOSJoinGameGroup(int requestId, const char *groupId) + { + [[FBUnityInterface sharedInstance] showJoinAppGroupDialogWithRequestId:requestId groupId:groupId]; + } + + void IOSCreateGameGroup(int requestId, const char *groupName, const char *groupDescription, const char *groupPrivacy) + { + [[FBUnityInterface sharedInstance] showCreateAppGroupDialogWithRequestId:requestId groupName:groupName groupDescription:groupDescription groupPrivacy:groupPrivacy]; + } + + void IOSFBSettingsActivateApp(const char *appId) + { + [FBSDKAppEvents 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 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 logPurchase:amount currency:[FBUnityUtility stringFromCString:currency] parameters:params]; + } + + void IOSFBAppEventsSetLimitEventUsage(BOOL limitEventUsage) + { + [FBSDKSettings setLimitEventAndDataUsage:limitEventUsage]; + } + + char* IOSFBSdkVersion() + { + const char* string = [[FBSDKSettings sdkVersion] UTF8String]; + char* res = (char*)malloc(strlen(string) + 1); + strcpy(res, string); + return res; + } + + void IOSFetchDeferredAppLink(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]; + }]; + } +} diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityInterface.mm.meta b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityInterface.mm.meta new file mode 100644 index 000000000..99f13d3cf --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityInterface.mm.meta @@ -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: diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnitySDKDelegate.h b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnitySDKDelegate.h new file mode 100644 index 000000000..e24a15adb --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnitySDKDelegate.h @@ -0,0 +1,48 @@ +// 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 + +extern NSString *const FBUnityMessageName_OnAppRequestsComplete; +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; + +/*! + @abstract A helper class that implements various FBSDK delegates in order to send + messages back to Unity. + */ +@interface FBUnitySDKDelegate : NSObject< + FBSDKAppGroupAddDialogDelegate, + FBSDKAppGroupJoinDialogDelegate, + FBSDKGameRequestDialogDelegate, + FBSDKSharingDelegate, + FBSDKAppInviteDialogDelegate> + +/* + @abstract returns a self retaining instance that is released once it receives a + delegate message from FBSDK. + */ ++ (instancetype)instanceWithRequestID:(int)requestID; + +@end diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnitySDKDelegate.h.meta b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnitySDKDelegate.h.meta new file mode 100644 index 000000000..e50d15bb6 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnitySDKDelegate.h.meta @@ -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: diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnitySDKDelegate.m b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnitySDKDelegate.m new file mode 100644 index 000000000..204d92584 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnitySDKDelegate.m @@ -0,0 +1,171 @@ +// 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 "FBUnitySDKDelegate.h" + +#import "FBUnityUtility.h" + +NSString *const FBUnityMessageName_OnAppRequestsComplete = @"OnAppRequestsComplete"; +NSString *const FBUnityMessageName_OnGetAppLinkComplete = @"OnGetAppLinkComplete"; +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_OnAppInviteComplete = @"OnAppInviteComplete"; +NSString *const FBUnityMessageName_OnFetchDeferredAppLinkComplete = @"OnFetchDeferredAppLinkComplete"; + +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 - AppGroupAddDelegate + +- (void)appGroupAddDialog:(FBSDKAppGroupAddDialog *)appGroupAddDialog didCompleteWithResults:(NSDictionary *)results +{ + [FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnGroupCreateComplete userData:results requestId:_requestID]; + [self complete]; +} + +- (void)appGroupAddDialog:(FBSDKAppGroupAddDialog *)appGroupAddDialog didFailWithError:(NSError *)error +{ + [FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnGroupCreateComplete error:error requestId:_requestID]; + [self complete]; +} + +- (void)appGroupAddDialogDidCancel:(FBSDKAppGroupAddDialog *)appGroupAddDialog +{ + [FBUnityUtility sendCancelToUnity:FBUnityMessageName_OnGroupCreateComplete requestId:_requestID]; + [self complete]; +} + +#pragma mark - AppGroupJoinDelegate + +- (void)appGroupJoinDialog:(FBSDKAppGroupJoinDialog *)appGroupJoinDialog didCompleteWithResults:(NSDictionary *)results +{ + [FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnGroupJoinComplete userData:results requestId:_requestID]; + [self complete]; +} + +- (void)appGroupJoinDialog:(FBSDKAppGroupJoinDialog *)appGroupJoinDialog didFailWithError:(NSError *)error +{ + [FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnGroupJoinComplete error:error requestId:_requestID]; + [self complete]; +} + +- (void)appGroupJoinDialogDidCancel:(FBSDKAppGroupJoinDialog *)appGroupJoinDialog +{ + [FBUnityUtility sendCancelToUnity:FBUnityMessageName_OnGroupJoinComplete requestId:_requestID]; + [self complete]; +} + +#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)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)sharer didFailWithError:(NSError *)error +{ + [FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnShareLinkComplete error:error requestId:_requestID]; + [self complete]; +} + +- (void)sharerDidCancel:(id)sharer +{ + [FBUnityUtility sendCancelToUnity:FBUnityMessageName_OnShareLinkComplete requestId:_requestID]; + [self complete]; +} + +#pragma mark - FBSDKAppInviteDialogDelegate + +- (void)appInviteDialog:(FBSDKAppInviteDialog *)appInviteDialog 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" }; + } else if([[results objectForKey:@"completionGesture"] isEqualToString:@"cancel"]) { + // The app invitie dialog doesn't have a cancel but returns "completionGesture" "cancel" + [FBUnityUtility sendCancelToUnity:FBUnityMessageName_OnAppInviteComplete requestId:_requestID]; + [self complete]; + } + + [FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnAppInviteComplete userData:results requestId:_requestID]; + [self complete]; +} + +- (void)appInviteDialog:(FBSDKAppInviteDialog *)appInviteDialog didFailWithError:(NSError *)error +{ + [FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnAppInviteComplete error:error requestId:_requestID]; + [self complete]; +} + +@end diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnitySDKDelegate.m.meta b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnitySDKDelegate.m.meta new file mode 100644 index 000000000..f9e65b5ab --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnitySDKDelegate.m.meta @@ -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: diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityUtility.h b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityUtility.h new file mode 100644 index 000000000..bc489d620 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityUtility.h @@ -0,0 +1,33 @@ +// 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 + +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; +@end diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityUtility.h.meta b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityUtility.h.meta new file mode 100644 index 000000000..efbec89a4 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityUtility.h.meta @@ -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: diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityUtility.mm b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityUtility.mm new file mode 100644 index 000000000..401cf9ba6 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityUtility.mm @@ -0,0 +1,175 @@ +// 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 +#import + +#import +#import +#import + +#import + +const char* const FB_OBJECT_NAME = "UnityFacebookSDKPlugin"; + +// Helper method to create C string copy +char* MakeStringCopy (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)sendErrorToUnity:(NSString *)unityMessage + error:(NSError *)error + requestId:(int)requestId +{ + [self sendErrorToUnity:unityMessage errorMessage:[error localizedDescription] 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], MakeStringCopy(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:@"non_app_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"]; + BFURL *parsedUrl = [BFURL 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; +} + +@end diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityUtility.mm.meta b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityUtility.mm.meta new file mode 100644 index 000000000..9f789edea --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/FBUnityUtility.mm.meta @@ -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: diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/FacebookSDK.meta b/Facebook.Unity/Assets/Facebook/Editor/iOS/FacebookSDK.meta new file mode 100644 index 000000000..478ab034a --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/FacebookSDK.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: db21fba8277bc4a159571568de32c0cb +folderAsset: yes +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/FixupFiles.cs b/Facebook.Unity/Assets/Facebook/Editor/iOS/FixupFiles.cs new file mode 100644 index 000000000..b7497039b --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/FixupFiles.cs @@ -0,0 +1,143 @@ +/** + * 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. + */ + +namespace UnityEditor.FacebookEditor +{ + using System; + using System.IO; + using System.Text.RegularExpressions; + using Facebook.Unity; + using UnityEditor; + using UnityEngine; + + public class FixupFiles + { + private static string didFinishLaunchingWithOptions = +@"(?x) # Verbose mode + (didFinishLaunchingWithOptions.+ # Find this function... + (?:.*\n)+? # Match as few lines as possible until... + \s*return\ )NO(\;\n # return NO; + \}) # }"; + + public static void FixSimulator(string path) + { + string fullPath = Path.Combine(path, Path.Combine("Libraries", "RegisterMonoModules.cpp")); + string data = Load(fullPath); + + data = Regex.Replace(data, @"\s+void\s+mono_dl_register_symbol\s+\(const\s+char\*\s+name,\s+void\s+\*addr\);", string.Empty); + data = Regex.Replace(data, "typedef int gboolean;", "typedef int gboolean;\n\tvoid mono_dl_register_symbol (const char* name, void *addr);"); + + // this only need to be done for unity 4, unity 5 declares user functions correctly + if (GetUnityVersionNumber() < 500) + { + data = Regex.Replace( + data, + @"#endif\s+//\s*!\s*\(\s*TARGET_IPHONE_SIMULATOR\s*\)\s*}\s*void RegisterAllStrippedInternalCalls\s*\(\s*\)", + "}\n\nvoid RegisterAllStrippedInternalCalls()"); + data = Regex.Replace( + data, + @"mono_aot_register_module\(mono_aot_module_mscorlib_info\);", + "mono_aot_register_module(mono_aot_module_mscorlib_info);\n#endif // !(TARGET_IPHONE_SIMULATOR)"); + } + + Save(fullPath, data); + } + + public static void AddVersionDefine(string path) + { + int versionNumber = GetUnityVersionNumber(); + + string fullPath = Path.Combine(path, Path.Combine("Libraries", "RegisterMonoModules.h")); + string data = Load(fullPath); + + if (versionNumber >= 430) + { + data += "\n#define HAS_UNITY_VERSION_DEF 1\n"; + } + else + { + data += "\n#define UNITY_VERSION "; + data += versionNumber; + data += "\n"; + } + + Save(fullPath, data); + } + + public static void FixColdStart(string path) + { + string fullPath = Path.Combine(path, Path.Combine("Classes", "UnityAppController.mm")); + string data = Load(fullPath); + + data = Regex.Replace( + data, + didFinishLaunchingWithOptions, + "$1YES$2"); + + Save(fullPath, data); + } + + protected static string Load(string fullPath) + { + string data; + FileInfo projectFileInfo = new FileInfo(fullPath); + StreamReader fs = projectFileInfo.OpenText(); + data = fs.ReadToEnd(); + fs.Close(); + + return data; + } + + protected static void Save(string fullPath, string data) + { + System.IO.StreamWriter writer = new System.IO.StreamWriter(fullPath, false); + writer.Write(data); + writer.Close(); + } + + private static int GetUnityVersionNumber() + { + string version = Application.unityVersion; + string[] versionComponents = version.Split('.'); + + int majorVersion = 0; + int minorVersion = 0; + + try + { + if (versionComponents != null && versionComponents.Length > 0 && versionComponents[0] != null) + { + majorVersion = Convert.ToInt32(versionComponents[0]); + } + + if (versionComponents != null && versionComponents.Length > 1 && versionComponents[1] != null) + { + minorVersion = Convert.ToInt32(versionComponents[1]); + } + } + catch (System.Exception e) + { + Debug.LogError("Error parsing Unity version number: " + e); + } + + return (majorVersion * 100) + (minorVersion * 10); + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/FixupFiles.cs.meta b/Facebook.Unity/Assets/Facebook/Editor/iOS/FixupFiles.cs.meta new file mode 100644 index 000000000..57acce6af --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/FixupFiles.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2f2d2f6bb31044a4f9eef36d7cc60ede +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/PListDict.cs b/Facebook.Unity/Assets/Facebook/Editor/iOS/PListDict.cs new file mode 100644 index 000000000..30be2c2f2 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/PListDict.cs @@ -0,0 +1,165 @@ +/** + * 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. + */ + +namespace UnityEditor.FacebookEditor +{ + using System; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Xml; + using System.Xml.Linq; + + public class PListDict : Dictionary + { + public PListDict() + { + } + + public PListDict(PListDict dict) : base(dict) + { + } + + public PListDict(XElement dict) + { + this.Load(dict); + } + + public void Load(XElement dict) + { + var dictElements = dict.Elements(); + this.ParseDictForLoad(this, dictElements); + } + + public void Save(string fileName, XDeclaration declaration, XDocumentType docType) + { + XElement plistNode = new XElement("plist", this.ParseDictForSave(this)); + plistNode.SetAttributeValue("version", "1.0"); + XDocument file = new XDocument(declaration, docType); + file.Add(plistNode); + file.Save(fileName); + } + + public XElement ParseValueForSave(object node) + { + if (node is string) + { + return new XElement("string", node); + } + else if (node is bool) + { + return new XElement(node.ToString().ToLower()); + } + else if (node is int) + { + return new XElement("integer", node); + } + else if (node is float) + { + return new XElement("real", node); + } + else if (node is IList) + { + return this.ParseArrayForSave(node); + } + else if (node is PListDict) + { + return this.ParseDictForSave((PListDict)node); + } + else if (node == null) + { + return null; + } + + throw new NotSupportedException("Unexpected type: " + node.GetType().FullName); + } + + private void ParseDictForLoad(PListDict dict, IEnumerable elements) + { + for (int i = 0; i < elements.Count(); i += 2) + { + XElement key = elements.ElementAt(i); + XElement val = elements.ElementAt(i + 1); + dict[key.Value] = this.ParseValueForLoad(val); + } + } + + private IList ParseArrayForLoad(IEnumerable elements) + { + var list = new List(); + foreach (XElement e in elements) + { + object one = this.ParseValueForLoad(e); + list.Add(one); + } + + return list; + } + + private object ParseValueForLoad(XElement val) + { + switch (val.Name.ToString()) + { + case "string": + return val.Value; + case "integer": + return int.Parse(val.Value); + case "real": + return float.Parse(val.Value); + case "true": + return true; + case "false": + return false; + case "dict": + PListDict plist = new PListDict(); + this.ParseDictForLoad(plist, val.Elements()); + return plist; + case "array": + return this.ParseArrayForLoad(val.Elements()); + default: + throw new ArgumentException("Format unsupported, Parser update needed"); + } + } + + private XElement ParseDictForSave(PListDict dict) + { + XElement dictNode = new XElement("dict"); + foreach (string key in dict.Keys) + { + dictNode.Add(new XElement("key", key)); + dictNode.Add(this.ParseValueForSave(dict[key])); + } + + return dictNode; + } + + private XElement ParseArrayForSave(object node) + { + XElement arrayNode = new XElement("array"); + var array = (IList)node; + for (int i = 0; i < array.Count; i++) + { + arrayNode.Add(this.ParseValueForSave(array[i])); + } + + return arrayNode; + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/PListDict.cs.meta b/Facebook.Unity/Assets/Facebook/Editor/iOS/PListDict.cs.meta new file mode 100644 index 000000000..209e1376a --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/PListDict.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ed50c46dfcb1c4661a67be08581213f8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/PListParser.cs b/Facebook.Unity/Assets/Facebook/Editor/iOS/PListParser.cs new file mode 100644 index 000000000..34f256d7a --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/PListParser.cs @@ -0,0 +1,243 @@ +/** + * 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. + */ + +namespace UnityEditor.FacebookEditor +{ + using System; + using System.Collections.Generic; + using System.IO; + using System.Text; + using System.Xml; + using System.Xml.Linq; + using Facebook.Unity.Editor; + using UnityEngine; + + internal class PListParser + { + private const string LSApplicationQueriesSchemesKey = "LSApplicationQueriesSchemes"; + private const string NSAppTransportSecurityKey = "NSAppTransportSecurity"; + private const string NSExceptionDomainsKey = "NSExceptionDomains"; + private const string NSIncludesSubdomainsKey = "NSIncludesSubdomains"; + private const string NSExceptionRequiresForwardSecrecyKey = "NSExceptionRequiresForwardSecrecy"; + private const string CFBundleURLTypesKey = "CFBundleURLTypes"; + private const string CFBundleURLSchemesKey = "CFBundleURLSchemes"; + private const string CFBundleURLName = "CFBundleURLName"; + private const string FacebookCFBundleURLName = "facebook-unity-sdk"; + private const string FacebookAppIDKey = "FacebookAppID"; + private const string FacebookAppIDPrefix = "fb"; + + private static readonly IList FacebookLSApplicationQueriesSchemes = new List() + { + "fbapi", + "fb-messenger-api", + "fbauth2", + "fbshareextension" + }; + + private static readonly PListDict FacebookNSExceptionDomainsEntry = new PListDict() + { + { NSIncludesSubdomainsKey, true }, + { NSExceptionRequiresForwardSecrecyKey, false } + }; + + private static readonly PListDict FacebookNSExceptionDomainsKey = new PListDict() + { + { "facebook.com", new PListDict(FacebookNSExceptionDomainsEntry) }, + { "fbcdn.net", new PListDict(FacebookNSExceptionDomainsEntry) }, + { "akamaihd.net", new PListDict(FacebookNSExceptionDomainsEntry) }, + }; + + private static readonly PListDict FacebookNSAppTransportSecurity = new PListDict() + { + { PListParser.NSExceptionDomainsKey, FacebookNSExceptionDomainsKey } + }; + + private static readonly PListDict FacebookUrlSchemes = new PListDict() + { + { PListParser.CFBundleURLName, PListParser.FacebookCFBundleURLName }, + }; + + private string filePath; + + public PListParser(string fullPath) + { + this.filePath = fullPath; + XmlReaderSettings settings = new XmlReaderSettings(); + settings.ProhibitDtd = false; + XmlReader plistReader = XmlReader.Create(this.filePath, settings); + + XDocument doc = XDocument.Load(plistReader); + XElement plist = doc.Element("plist"); + XElement dict = plist.Element("dict"); + this.XMLDict = new PListDict(dict); + plistReader.Close(); + } + + public PListDict XMLDict { get; set; } + + public void UpdateFBSettings(string appID, string urlSuffix, ICollection appLinkSchemes) + { + // Set the facbook app ID + this.XMLDict[PListParser.FacebookAppIDKey] = appID; + + // Set the requried schemas for this app + SetCFBundleURLSchemes(this.XMLDict, appID, urlSuffix, appLinkSchemes); + + // iOS 9+ Support + WhilelistFacebookServersForNetworkRequests(this.XMLDict); + WhitelistFacebookApps(this.XMLDict); + } + + public void WriteToFile() + { + // Corrected header of the plist + string publicId = "-//Apple//DTD PLIST 1.0//EN"; + string stringId = "http://www.apple.com/DTDs/PropertyList-1.0.dtd"; + string internalSubset = null; + XDeclaration declaration = new XDeclaration("1.0", Encoding.UTF8.EncodingName, null); + XDocumentType docType = new XDocumentType("plist", publicId, stringId, internalSubset); + + this.XMLDict.Save(this.filePath, declaration, docType); + } + + private static void WhilelistFacebookServersForNetworkRequests(PListDict plistDict) + { + if (!ContainsKeyWithValueType(plistDict, PListParser.NSAppTransportSecurityKey, typeof(PListDict))) + { + // We don't have a NSAppTransportSecurity entry. We can easily add one + plistDict[PListParser.NSAppTransportSecurityKey] = PListParser.FacebookNSAppTransportSecurity; + return; + } + + var appTransportSecurityDict = (PListDict)plistDict[PListParser.NSAppTransportSecurityKey]; + if (!ContainsKeyWithValueType(appTransportSecurityDict, PListParser.NSExceptionDomainsKey, typeof(PListDict))) + { + appTransportSecurityDict[PListParser.NSExceptionDomainsKey] = PListParser.FacebookNSExceptionDomainsEntry; + return; + } + + var exceptionDomains = (PListDict)appTransportSecurityDict[PListParser.NSExceptionDomainsKey]; + foreach (var key in PListParser.FacebookNSExceptionDomainsEntry.Keys) + { + // Instead of just updating overwrite values to keep things up to date + exceptionDomains[key] = FacebookNSExceptionDomainsEntry[key]; + } + } + + private static void WhitelistFacebookApps(PListDict plistDict) + { + if (!ContainsKeyWithValueType(plistDict, PListParser.LSApplicationQueriesSchemesKey, typeof(IList))) + { + // We don't have a LSApplicationQueriesSchemes entry. We can easily add one + plistDict[PListParser.LSApplicationQueriesSchemesKey] = PListParser.FacebookLSApplicationQueriesSchemes; + return; + } + + var applicationQueriesSchemes = (IList)plistDict[PListParser.LSApplicationQueriesSchemesKey]; + foreach (var scheme in PListParser.FacebookLSApplicationQueriesSchemes) + { + if (!applicationQueriesSchemes.Contains(scheme)) + { + applicationQueriesSchemes.Add(scheme); + } + } + } + + private static void SetCFBundleURLSchemes( + PListDict plistDict, + string appID, + string urlSuffix, + ICollection appLinkSchemes) + { + IList currentSchemas; + if (ContainsKeyWithValueType(plistDict, PListParser.CFBundleURLTypesKey, typeof(IList))) + { + currentSchemas = (IList)plistDict[PListParser.CFBundleURLTypesKey]; + } + else + { + // Didn't find any CFBundleURLTypes, let's create one + currentSchemas = new List(); + plistDict[PListParser.CFBundleURLTypesKey] = currentSchemas; + } + + PListDict facebookBundleUrlSchemes = PListParser.GetFacebookUrlSchemes(currentSchemas); + + // Clear and set the CFBundleURLSchemes for the facebook schemes + var facebookUrlSchemes = new List(); + facebookBundleUrlSchemes[PListParser.CFBundleURLSchemesKey] = facebookUrlSchemes; + AddAppID(facebookUrlSchemes, appID, urlSuffix); + AddAppLinkSchemes(facebookUrlSchemes, appLinkSchemes); + } + + private static PListDict GetFacebookUrlSchemes(ICollection plistSchemes) + { + foreach (var plistScheme in plistSchemes) + { + var bundleTypeNode = plistScheme as PListDict; + if (bundleTypeNode != null) + { + // Check to see if the url scheme name is facebook + string bundleURLName; + if (bundleTypeNode.TryGetValue(PListParser.CFBundleURLName, out bundleURLName) && + bundleURLName == PListParser.FacebookCFBundleURLName) + { + return bundleTypeNode; + } + } + } + + // We didn't find a facebook scheme so lets create one + PListDict facebookUrlSchemes = new PListDict(PListParser.FacebookUrlSchemes); + plistSchemes.Add(facebookUrlSchemes); + return facebookUrlSchemes; + } + + private static void AddAppID(ICollection schemesCollection, string appID, string urlSuffix) + { + string modifiedID = PListParser.FacebookAppIDPrefix + appID; + if (!string.IsNullOrEmpty(urlSuffix)) + { + modifiedID += urlSuffix; + } + + schemesCollection.Add((object)modifiedID); + } + + private static void AddAppLinkSchemes(ICollection schemesCollection, ICollection appLinkSchemes) + { + foreach (var appLinkScheme in appLinkSchemes) + { + schemesCollection.Add(appLinkScheme); + } + } + + private static bool ContainsKeyWithValueType(IDictionary dictionary, string key, Type type) + { + if (dictionary.ContainsKey(key) && + type.IsAssignableFrom(dictionary[key].GetType())) + { + return true; + } + + return false; + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/PListParser.cs.meta b/Facebook.Unity/Assets/Facebook/Editor/iOS/PListParser.cs.meta new file mode 100644 index 000000000..b022a1224 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/PListParser.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ff81f50950f8a428bae1b08e556fb474 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/fixup.projmods b/Facebook.Unity/Assets/Facebook/Editor/iOS/fixup.projmods new file mode 100644 index 000000000..1a223f287 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/fixup.projmods @@ -0,0 +1,24 @@ +{ + "group": "Facebook", + "patches": [], + "libs": [ + "libsqlite3.0.dylib:weak", + ], + "librarysearchpaths": [ + ], + "frameworks": [ + "Accounts.framework:weak", + "AdSupport.framework:weak", + "Social.framework:weak", + "Security.framework:weak", + ], + "headerpaths": [ + "Facebook/Editor/iOS", + "Facebook/Scripts" + ], + "files": [ + "Facebook/Scripts/NativeDialogModes.cs", + ], + "folders": [], + "excludes": ["^.*\\.meta$", "^.*\\.mdown^", "^.*\\.pdf$"] +} diff --git a/Facebook.Unity/Assets/Facebook/Editor/iOS/fixup.projmods.meta b/Facebook.Unity/Assets/Facebook/Editor/iOS/fixup.projmods.meta new file mode 100644 index 000000000..06e802665 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Editor/iOS/fixup.projmods.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: aead30834362b490ea67fdd7fd0351c5 +DefaultImporter: + userData: diff --git a/Facebook.Unity/Assets/Facebook/Prefabs.meta b/Facebook.Unity/Assets/Facebook/Prefabs.meta new file mode 100644 index 000000000..7a607f132 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Prefabs.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: a5b8fa2bcc25144fd849240c6e313b72 +folderAsset: yes +timeCreated: 1439938433 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Resources.meta b/Facebook.Unity/Assets/Facebook/Resources.meta new file mode 100644 index 000000000..c5c6de2b3 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Resources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5d3a9d101a6e94e0481189e1f7a68510 +folderAsset: yes +timeCreated: 1432677675 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts.meta b/Facebook.Unity/Assets/Facebook/Scripts.meta new file mode 100644 index 000000000..891f3f25e --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 81be61da4386c974d900e208f041683b +folderAsset: yes +DefaultImporter: + userData: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/AccessToken.cs b/Facebook.Unity/Assets/Facebook/Scripts/AccessToken.cs new file mode 100644 index 000000000..6f75cc504 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/AccessToken.cs @@ -0,0 +1,114 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using UnityEngine; + + /// + /// Contains the access token and related information. + /// + public class AccessToken + { + /// + /// Initializes a new instance of the class. + /// + /// Token string. + /// User identifier. + /// Expiration time. + /// Permissions. + public AccessToken( + string tokenString, + string userId, + DateTime expirationTime, + IEnumerable permissions) + { + if (string.IsNullOrEmpty(tokenString)) + { + throw new ArgumentNullException("tokenString"); + } + + if (string.IsNullOrEmpty(userId)) + { + throw new ArgumentNullException("userId"); + } + + if (expirationTime == DateTime.MinValue) + { + throw new ArgumentException("Expiration time is unassigned"); + } + + if (permissions == null) + { + throw new ArgumentNullException("permissions"); + } + + this.TokenString = tokenString; + this.ExpirationTime = expirationTime; + this.Permissions = permissions; + this.UserId = userId; + } + + /// + /// Gets or sets the current access token. + /// + /// The current access token. + public static AccessToken CurrentAccessToken { get; internal set; } + + /// + /// Gets or sets the token string. + /// + /// The token string. + public string TokenString { get; internal set; } + + /// + /// Gets or sets the expiration time. + /// + /// The expiration time. + public DateTime ExpirationTime { get; internal set; } + + /// + /// Gets or sets the list of permissions. + /// + /// The permissions. + public IEnumerable Permissions { get; internal set; } + + /// + /// Gets or sets the user identifier. + /// + /// The user identifier. + public string UserId { get; internal set; } + + internal string ToJson() + { + var dictionary = new Dictionary(); + dictionary[LoginResult.PermissionsKey] = string.Join(",", this.Permissions.ToArray()); + dictionary[LoginResult.ExpirationTimestampKey] = this.ExpirationTime.TotalSeconds().ToString(); + dictionary[LoginResult.AccessTokenKey] = this.TokenString; + dictionary[LoginResult.UserIdKey] = this.UserId; + + return MiniJSON.Json.Serialize(dictionary); + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/AccessToken.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/AccessToken.cs.meta new file mode 100644 index 000000000..156b9e464 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/AccessToken.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1b3c88d71f0144c36bd092ed664ad232 +timeCreated: 1436300842 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/AppEventName.cs b/Facebook.Unity/Assets/Facebook/Scripts/AppEventName.cs new file mode 100644 index 000000000..43a635894 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/AppEventName.cs @@ -0,0 +1,43 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + /// + /// Contains the names used for standard App Events. + /// + public static class AppEventName + { + public const string AchievedLevel = "fb_mobile_level_achieved"; + public const string ActivatedApp = "fb_mobile_activate_app"; + public const string AddedPaymentInfo = "fb_mobile_add_payment_info"; + public const string AddedToCart = "fb_mobile_add_to_cart"; + public const string AddedToWishlist = "fb_mobile_add_to_wishlist"; + public const string CompletedRegistration = "fb_mobile_complete_registration"; + public const string CompletedTutorial = "fb_mobile_tutorial_completion"; + public const string InitiatedCheckout = "fb_mobile_initiated_checkout"; + public const string Purchased = "fb_mobile_purchase"; + public const string Rated = "fb_mobile_rate"; + public const string Searched = "fb_mobile_search"; + public const string SpentCredits = "fb_mobile_spent_credits"; + public const string UnlockedAchievement = "fb_mobile_achievement_unlocked"; + public const string ViewedContent = "fb_mobile_content_view"; + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/AppEventName.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/AppEventName.cs.meta new file mode 100644 index 000000000..959d14fb1 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/AppEventName.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 46b0769c828c34b4093859f09779a9e6 +timeCreated: 1437500989 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/AppEventParameterName.cs b/Facebook.Unity/Assets/Facebook/Scripts/AppEventParameterName.cs new file mode 100644 index 000000000..f09e80b62 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/AppEventParameterName.cs @@ -0,0 +1,40 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + /// + /// Contains the parameter names used for standard App Events. + /// + public static class AppEventParameterName + { + public const string ContentID = "fb_content_id"; + public const string ContentType = "fb_content_type"; + public const string Currency = "fb_currency"; + public const string Description = "fb_description"; + public const string Level = "fb_level"; + public const string MaxRatingValue = "fb_max_rating_value"; + public const string NumItems = "fb_num_items"; + public const string PaymentInfoAvailable = "fb_payment_info_available"; + public const string RegistrationMethod = "fb_registration_method"; + public const string SearchString = "fb_search_string"; + public const string Success = "fb_success"; + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/AppEventParameterName.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/AppEventParameterName.cs.meta new file mode 100644 index 000000000..671822e2e --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/AppEventParameterName.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 133a278d47e7143fe815b0f2c9b9fb56 +timeCreated: 1437500989 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/CallbackManager.cs b/Facebook.Unity/Assets/Facebook/Scripts/CallbackManager.cs new file mode 100644 index 000000000..774ee857e --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/CallbackManager.cs @@ -0,0 +1,93 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using System; + using System.Collections.Generic; + + internal class CallbackManager + { + private IDictionary facebookDelegates = new Dictionary(); + private int nextAsyncId; + + public string AddFacebookDelegate(FacebookDelegate callback) where T : IResult + { + if (callback == null) + { + return null; + } + + this.nextAsyncId++; + this.facebookDelegates.Add(this.nextAsyncId.ToString(), callback); + return this.nextAsyncId.ToString(); + } + + public void OnFacebookResponse(IInternalResult result) + { + if (result == null || result.CallbackId == null) + { + return; + } + + object callback; + if (this.facebookDelegates.TryGetValue(result.CallbackId, out callback)) + { + CallCallback(callback, result); + this.facebookDelegates.Remove(result.CallbackId); + } + } + + // Since unity mono doesn't support covariance and contravariance use this hack + private static void CallCallback(object callback, IResult result) + { + if (callback == null || result == null) + { + return; + } + + if (CallbackManager.TryCallCallback(callback, result) || + CallbackManager.TryCallCallback(callback, result) || + CallbackManager.TryCallCallback(callback, result) || + CallbackManager.TryCallCallback(callback, result) || + CallbackManager.TryCallCallback(callback, result) || + CallbackManager.TryCallCallback(callback, result) || + CallbackManager.TryCallCallback(callback, result) || + CallbackManager.TryCallCallback(callback, result)) + { + return; + } + + throw new NotSupportedException("Unexpected result type: " + callback.GetType().FullName); + } + + private static bool TryCallCallback(object callback, IResult result) where T : IResult + { + var castedCallback = callback as FacebookDelegate; + if (castedCallback != null) + { + castedCallback((T)result); + return true; + } + + return false; + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/CallbackManager.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/CallbackManager.cs.meta new file mode 100644 index 000000000..c8f5bf409 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/CallbackManager.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 42872ce86630f4590b58b7eca72f636e +timeCreated: 1438289533 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Canvas.meta b/Facebook.Unity/Assets/Facebook/Scripts/Canvas.meta new file mode 100644 index 000000000..494bb8461 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Canvas.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 9e692439815dc4b4282824d2dbe2cc5c +folderAsset: yes +timeCreated: 1438298352 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebook.cs b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebook.cs new file mode 100644 index 000000000..de545cca0 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebook.cs @@ -0,0 +1,493 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Canvas +{ + using System; + using System.Collections.Generic; + using System.IO; + using UnityEngine; + + internal sealed class CanvasFacebook : FacebookBase, ICanvasFacebookImplementation + { + internal const string MethodAppRequests = "apprequests"; + internal const string MethodFeed = "feed"; + internal const string MethodPay = "pay"; + internal const string MethodGameGroupCreate = "game_group_create"; + internal const string MethodGameGroupJoin = "game_group_join"; + internal const string CancelledResponse = "{\"cancelled\":true}"; + internal const string FacebookConnectURL = "https://connect.facebook.net"; + internal const string SDKVersion = "v2.4"; + + private const string AuthResponseKey = "authResponse"; + private const string ResponseKey = "response"; + + // The source code for our js sdk binding. + private const string JSSDKBindingFileName = "JSSDKBindings"; + private const string SDKLocale = "en_US"; + + private string appId; + private bool sdkDebug = false; + private string appLinkUrl; + + public CanvasFacebook() + : this(new CallbackManager()) + { + } + + public CanvasFacebook(CallbackManager callbackManager) + : base(callbackManager) + { + } + + public override bool LimitEventUsage { get; set; } + + public override string FacebookSdkVersion + { + get + { + return string.Format("Facebook.JS.SDK.{0}", SDKVersion); + } + } + + private static string IntegrationMethodJs + { + get + { + TextAsset ta = Resources.Load(JSSDKBindingFileName) as TextAsset; + if (ta) + { + return ta.text; + } + + return null; + } + } + + public override void Init( + string appId, + bool cookie, + bool logging, + bool status, + bool xfbml, + string channelUrl, + string authResponse, + bool frictionlessRequests, + HideUnityDelegate hideUnityDelegate, + InitDelegate onInitComplete) + { + if (CanvasFacebook.IntegrationMethodJs == null) + { + throw new Exception("Cannot initialize facebook javascript"); + } + + base.Init( + appId, + cookie, + logging, + status, + xfbml, + channelUrl, + authResponse, + frictionlessRequests, + hideUnityDelegate, + onInitComplete); + + Application.ExternalEval(CanvasFacebook.IntegrationMethodJs); + this.appId = appId; + + bool isPlayer = true; + #if UNITY_WEBGL + isPlayer = false; + #endif + + MethodArguments parameters = new MethodArguments(); + parameters.AddString("appId", appId); + parameters.AddPrimative("cookie", cookie); + parameters.AddPrimative("logging", logging); + parameters.AddPrimative("status", status); + parameters.AddPrimative("xfbml", xfbml); + parameters.AddString("channelUrl", channelUrl); + parameters.AddString("authResponse", authResponse); + parameters.AddPrimative("frictionlessRequests", frictionlessRequests); + parameters.AddString("version", SDKVersion); + + // use 1/0 for booleans, otherwise you'll get strings "True"/"False" + Application.ExternalCall( + "FBUnity.init", + isPlayer ? 1 : 0, + FacebookConnectURL, + SDKLocale, + this.sdkDebug ? 1 : 0, + parameters.ToJsonString(), + status ? 1 : 0); + } + + public override void LogInWithPublishPermissions( + IEnumerable permissions, + FacebookDelegate callback) + { + if (Screen.fullScreen) + { + Screen.fullScreen = false; + } + + Application.ExternalCall("FBUnity.login", permissions, CallbackManager.AddFacebookDelegate(callback)); + } + + public override void LogInWithReadPermissions( + IEnumerable permissions, + FacebookDelegate callback) + { + if (Screen.fullScreen) + { + Screen.fullScreen = false; + } + + Application.ExternalCall("FBUnity.login", permissions, CallbackManager.AddFacebookDelegate(callback)); + } + + public override void LogOut() + { + base.LogOut(); + Application.ExternalCall("FBUnity.logout"); + } + + public override void AppRequest( + string message, + OGActionType? actionType, + string objectId, + IEnumerable to, + IEnumerable filters, + IEnumerable excludeIds, + int? maxRecipients, + string data, + string title, + FacebookDelegate callback) + { + this.ValidateAppRequestArgs( + message, + actionType, + objectId, + to, + filters, + excludeIds, + maxRecipients, + data, + title, + callback); + + MethodArguments args = new MethodArguments(); + args.AddString("message", message); + args.AddCommaSeparatedList("to", to); + args.AddString("action_type", actionType != null ? actionType.ToString() : null); + args.AddString("object_id", objectId); + args.AddList("filters", filters); + args.AddList("exclude_ids", excludeIds); + args.AddNullablePrimitive("max_recipients", maxRecipients); + args.AddString("data", data); + args.AddString("title", title); + var call = new CanvasUIMethodCall(this, MethodAppRequests, Constants.OnAppRequestsCompleteMethodName); + call.Callback = callback; + call.Call(args); + } + + public override void ActivateApp(string appId) + { + Application.ExternalCall("FBUnity.activateApp"); + } + + public override void ShareLink( + Uri contentURL, + string contentTitle, + string contentDescription, + Uri photoURL, + FacebookDelegate callback) + { + MethodArguments args = new MethodArguments(); + args.AddUri("link", contentURL); + args.AddString("name", contentTitle); + args.AddString("description", contentDescription); + args.AddUri("picture", photoURL); + var call = new CanvasUIMethodCall(this, MethodFeed, Constants.OnShareCompleteMethodName); + call.Callback = callback; + call.Call(args); + } + + public override void FeedShare( + string toId, + Uri link, + string linkName, + string linkCaption, + string linkDescription, + Uri picture, + string mediaSource, + FacebookDelegate callback) + { + MethodArguments args = new MethodArguments(); + args.AddString("to", toId); + args.AddUri("link", link); + args.AddString("name", linkName); + args.AddString("caption", linkCaption); + args.AddString("description", linkDescription); + args.AddUri("picture", picture); + args.AddString("source", mediaSource); + var call = new CanvasUIMethodCall(this, MethodFeed, Constants.OnShareCompleteMethodName); + call.Callback = callback; + call.Call(args); + } + + public void Pay( + string product, + string action, + int quantity, + int? quantityMin, + int? quantityMax, + string requestId, + string pricepointId, + string testCurrency, + FacebookDelegate callback) + { + MethodArguments args = new MethodArguments(); + args.AddString("product", product); + args.AddString("action", action); + args.AddPrimative("quantity", quantity); + args.AddNullablePrimitive("quantity_min", quantityMin); + args.AddNullablePrimitive("quantity_max", quantityMax); + args.AddString("request_id", requestId); + args.AddString("pricepoint_id", pricepointId); + args.AddString("test_currency", testCurrency); + var call = new CanvasUIMethodCall(this, MethodPay, Constants.OnPayCompleteMethodName); + call.Callback = callback; + call.Call(args); + } + + public override void GameGroupCreate( + string name, + string description, + string privacy, + FacebookDelegate callback) + { + MethodArguments args = new MethodArguments(); + args.AddString("name", name); + args.AddString("description", description); + args.AddString("privacy", privacy); + args.AddString("display", "async"); + var call = new CanvasUIMethodCall(this, MethodGameGroupCreate, Constants.OnGroupCreateCompleteMethodName); + call.Callback = callback; + call.Call(args); + } + + public override void GameGroupJoin( + string id, + FacebookDelegate callback) + { + MethodArguments args = new MethodArguments(); + args.AddString("id", id); + args.AddString("display", "async"); + var call = new CanvasUIMethodCall(this, MethodGameGroupJoin, Constants.OnJoinGroupCompleteMethodName); + call.Callback = callback; + call.Call(args); + } + + public override void GetAppLink(FacebookDelegate callback) + { + var result = new Dictionary() + { + { + "url", this.appLinkUrl + } + }; + callback(new AppLinkResult(MiniJSON.Json.Serialize(result))); + this.appLinkUrl = string.Empty; + } + + public override void AppEventsLogEvent( + string logEvent, + float? valueToSum, + Dictionary parameters) + { + Application.ExternalCall( + "FBUnity.logAppEvent", + logEvent, + valueToSum, + MiniJSON.Json.Serialize(parameters)); + } + + public override void AppEventsLogPurchase( + float logPurchase, + string currency, + Dictionary parameters) + { + Application.ExternalCall( + "FBUnity.logPurchase", + logPurchase, + currency, + MiniJSON.Json.Serialize(parameters)); + } + + public override void OnLoginComplete(string responseJsonData) + { + string formattedResponse = CanvasFacebook.FormatAuthResponse(responseJsonData); + this.OnAuthResponse(new LoginResult(formattedResponse)); + } + + public override void OnGetAppLinkComplete(string message) + { + // We should never get here on canvas. We store the app link on this object + // so should never hit this method. + throw new NotImplementedException(); + } + + // used only to refresh the access token + public void OnFacebookAuthResponseChange(string responseJsonData) + { + string formattedResponse = CanvasFacebook.FormatAuthResponse(responseJsonData); + var result = new LoginResult(formattedResponse); + AccessToken.CurrentAccessToken = result.AccessToken; + } + + public void OnPayComplete(string responseJsonData) + { + string formattedResponse = CanvasFacebook.FormatResult(responseJsonData); + var result = new PayResult(formattedResponse); + CallbackManager.OnFacebookResponse(result); + } + + public override void OnAppRequestsComplete(string responseJsonData) + { + string formattedResponse = CanvasFacebook.FormatResult(responseJsonData); + var result = new AppRequestResult(formattedResponse); + CallbackManager.OnFacebookResponse(result); + } + + public override void OnShareLinkComplete(string responseJsonData) + { + string formattedResponse = CanvasFacebook.FormatResult(responseJsonData); + var result = new ShareResult(formattedResponse); + CallbackManager.OnFacebookResponse(result); + } + + public override void OnGroupCreateComplete(string responseJsonData) + { + string formattedResponse = CanvasFacebook.FormatResult(responseJsonData); + var result = new GroupCreateResult(formattedResponse); + CallbackManager.OnFacebookResponse(result); + } + + public override void OnGroupJoinComplete(string responseJsonData) + { + string formattedResponse = CanvasFacebook.FormatResult(responseJsonData); + var result = new GroupJoinResult(formattedResponse); + CallbackManager.OnFacebookResponse(result); + } + + public void OnUrlResponse(string url) + { + this.appLinkUrl = url; + } + + private static string FormatAuthResponse(string result) + { + if (string.IsNullOrEmpty(result)) + { + return result; + } + + IDictionary responseDictionary = GetFormattedResponseDictionary(result); + IDictionary authResponse; + if (responseDictionary.TryGetValue(CanvasFacebook.AuthResponseKey, out authResponse)) + { + responseDictionary.Remove(CanvasFacebook.AuthResponseKey); + foreach (var item in authResponse) + { + responseDictionary[item.Key] = item.Value; + } + } + + return MiniJSON.Json.Serialize(responseDictionary); + } + + // This method converts the format of the result to match the format + // of our results from iOS and Android + private static string FormatResult(string result) + { + if (string.IsNullOrEmpty(result)) + { + return result; + } + + return MiniJSON.Json.Serialize(GetFormattedResponseDictionary(result)); + } + + private static IDictionary GetFormattedResponseDictionary(string result) + { + var resultDictionary = (IDictionary)MiniJSON.Json.Deserialize(result); + IDictionary responseDictionary; + if (resultDictionary.TryGetValue(CanvasFacebook.ResponseKey, out responseDictionary)) + { + object callbackId; + if (resultDictionary.TryGetValue(Constants.CallbackIdKey, out callbackId)) + { + responseDictionary[Constants.CallbackIdKey] = callbackId; + } + + return responseDictionary; + } + + return resultDictionary; + } + + private class CanvasUIMethodCall : MethodCall where T : IResult + { + private CanvasFacebook canvasImpl; + private string callbackMethod; + + public CanvasUIMethodCall(CanvasFacebook canvasImpl, string methodName, string callbackMethod) + : base(canvasImpl, methodName) + { + this.canvasImpl = canvasImpl; + this.callbackMethod = callbackMethod; + } + + public override void Call(MethodArguments args) + { + this.UI(this.MethodName, args, this.Callback); + } + + private void UI( + string method, + MethodArguments args, + FacebookDelegate callback = null) + { + if (Screen.fullScreen) + { + Screen.fullScreen = false; + } + + var clonedArgs = new MethodArguments(args); + clonedArgs.AddString("app_id", this.canvasImpl.appId); + clonedArgs.AddString("method", method); + var uniqueId = this.canvasImpl.CallbackManager.AddFacebookDelegate(callback); + Application.ExternalCall("FBUnity.ui", clonedArgs.ToJsonString(), uniqueId, this.callbackMethod); + } + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebook.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebook.cs.meta new file mode 100644 index 000000000..45ab00b27 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebook.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f850a8383aa964c38aec4b28cf61fe81 +timeCreated: 1438298352 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebookGameObject.cs b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebookGameObject.cs new file mode 100644 index 000000000..88d793719 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebookGameObject.cs @@ -0,0 +1,65 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Canvas +{ + using System; + using UnityEngine; + + internal class CanvasFacebookGameObject : FacebookGameObject, ICanvasFacebookCallbackHandler + { + protected ICanvasFacebookImplementation CanvasFacebookImpl + { + get + { + return (ICanvasFacebookImplementation)this.Facebook; + } + } + + public void OnPayComplete(string result) + { + this.CanvasFacebookImpl.OnPayComplete(result); + } + + public void OnFacebookAuthResponseChange(string message) + { + this.CanvasFacebookImpl.OnFacebookAuthResponseChange(message); + } + + public void OnUrlResponse(string message) + { + this.CanvasFacebookImpl.OnUrlResponse(message); + } + + public void OnHideUnity(bool hide) + { + this.CanvasFacebookImpl.OnHideUnity(hide); + } + + protected override void OnAwake() + { + // Facebook JS Bridge lives in it's own gameobject for optimization reasons + // see UnityObject.SendMessage() + var bridgeObject = new GameObject("FacebookJsBridge"); + bridgeObject.AddComponent(); + bridgeObject.transform.parent = gameObject.transform; + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebookGameObject.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebookGameObject.cs.meta new file mode 100644 index 000000000..8bbf5c279 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebookGameObject.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: de8722c5a13d94740bb1e2fccf7c23cd +timeCreated: 1438298352 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebookLoader.cs b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebookLoader.cs new file mode 100644 index 000000000..b103d8b7b --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebookLoader.cs @@ -0,0 +1,42 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Canvas +{ + using System.Collections; + using UnityEngine; + + internal class CanvasFacebookLoader : FB.CompiledFacebookLoader + { + protected override FacebookGameObject FBGameObject + { + get + { + CanvasFacebookGameObject canvasFB = ComponentFactory.GetComponent(); + if (canvasFB.Facebook == null) + { + canvasFB.Facebook = new CanvasFacebook(); + } + + return canvasFB; + } + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebookLoader.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebookLoader.cs.meta new file mode 100644 index 000000000..f35b352ab --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/CanvasFacebookLoader.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0c049b30f96ae43d5952b8edc8643a12 +timeCreated: 1438298352 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebook.cs b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebook.cs new file mode 100644 index 000000000..dee7045a4 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebook.cs @@ -0,0 +1,38 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Canvas +{ + using System; + + internal interface ICanvasFacebook : IFacebook + { + void Pay( + string product, + string action, + int quantity, + int? quantityMin, + int? quantityMax, + string requestId, + string pricepointId, + string testCurrency, + FacebookDelegate callback); + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebook.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebook.cs.meta new file mode 100644 index 000000000..16b752415 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebook.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 37770e9a2bfad477ebdbd46f905531b6 +timeCreated: 1438298352 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebookCallbackHandler.cs b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebookCallbackHandler.cs new file mode 100644 index 000000000..6db1e1535 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebookCallbackHandler.cs @@ -0,0 +1,38 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Canvas +{ + using System; + + internal interface ICanvasFacebookCallbackHandler : IFacebookCallbackHandler + { + void OnPayComplete(string message); + + // Called when the JSSDK event authResponseChange is fired when a user logins in + // Using something such as a login button from the JSSDK. + void OnFacebookAuthResponseChange(string message); + + // Used for deeplinking + void OnUrlResponse(string message); + + void OnHideUnity(bool hide); + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebookCallbackHandler.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebookCallbackHandler.cs.meta new file mode 100644 index 000000000..5ea8c3b1c --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebookCallbackHandler.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 48f337ac99e554cc29f3760ca7e2ea85 +timeCreated: 1438298352 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebookImplementation.cs b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebookImplementation.cs new file mode 100644 index 000000000..63aee9a7e --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebookImplementation.cs @@ -0,0 +1,28 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Canvas +{ + using System; + + internal interface ICanvasFacebookImplementation : ICanvasFacebook, ICanvasFacebookCallbackHandler + { + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebookImplementation.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebookImplementation.cs.meta new file mode 100644 index 000000000..83889b977 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/ICanvasFacebookImplementation.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6df61094741384b36a915ff642ba0e7c +timeCreated: 1438298352 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Canvas/JsBridge.cs b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/JsBridge.cs new file mode 100644 index 000000000..136cd73b2 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/JsBridge.cs @@ -0,0 +1,86 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Canvas +{ + using System.Collections.Generic; + using UnityEngine; + + internal class JsBridge : MonoBehaviour + { + private ICanvasFacebookCallbackHandler facebook; + + public void Start() + { + this.facebook = ComponentFactory.GetComponent( + ComponentFactory.IfNotExist.ReturnNull); + } + + public void OnLoginComplete(string responseJsonData = "") + { + this.facebook.OnLoginComplete(responseJsonData); + } + + public void OnFacebookAuthResponseChange(string responseJsonData = "") + { + this.facebook.OnFacebookAuthResponseChange(responseJsonData); + } + + public void OnPayComplete(string responseJsonData = "") + { + this.facebook.OnPayComplete(responseJsonData); + } + + public void OnAppRequestsComplete(string responseJsonData = "") + { + this.facebook.OnAppRequestsComplete(responseJsonData); + } + + public void OnShareLinkComplete(string responseJsonData = "") + { + this.facebook.OnShareLinkComplete(responseJsonData); + } + + public void OnGroupCreateComplete(string responseJsonData = "") + { + this.facebook.OnGroupCreateComplete(responseJsonData); + } + + public void OnJoinGroupComplete(string responseJsonData = "") + { + this.facebook.OnGroupJoinComplete(responseJsonData); + } + + public void OnFacebookFocus(string state) + { + this.facebook.OnHideUnity(state != "hide"); + } + + public void OnInitComplete(string responseJsonData = "") + { + this.facebook.OnInitComplete(responseJsonData); + } + + public void OnUrlResponse(string url = "") + { + this.facebook.OnUrlResponse(url); + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Canvas/JsBridge.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/JsBridge.cs.meta new file mode 100644 index 000000000..5bc8e3294 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/JsBridge.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 424a3e5478e07444781e488b6aaa6f9f +timeCreated: 1438298352 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Canvas/Resources.meta b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/Resources.meta new file mode 100644 index 000000000..f3cfbbbd9 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/Resources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 7afaf017a508d4c329c14d9ff24d73ba +folderAsset: yes +timeCreated: 1438298352 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Canvas/Resources/JSSDKBindings.txt b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/Resources/JSSDKBindings.txt new file mode 100644 index 000000000..bc68f162e --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/Resources/JSSDKBindings.txt @@ -0,0 +1,185 @@ +window.FBUnity = { + init: function(isPlayer, connectFacebookUrl, locale, debug, initParams, status) { + FBUnity.isPlayer = isPlayer; + // 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(); + } + }; + }, + + sendMessage: function(method, param) { + if (!FBUnity.isPlayer) { + SendMessage('FacebookJsBridge', method, param); + } else { + u.getUnity().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) }); + }, + + 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'); + } + } +}; + +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); + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Canvas/Resources/JSSDKBindings.txt.meta b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/Resources/JSSDKBindings.txt.meta new file mode 100644 index 000000000..2c7bbdf70 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Canvas/Resources/JSSDKBindings.txt.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b190819d72a914ba0af93e95735faffc +timeCreated: 1438298355 +licenseType: Pro +TextScriptImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/ComponentFactory.cs b/Facebook.Unity/Assets/Facebook/Scripts/ComponentFactory.cs new file mode 100644 index 000000000..c902982ed --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/ComponentFactory.cs @@ -0,0 +1,74 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using UnityEngine; + + internal class ComponentFactory + { + public const string GameObjectName = "UnityFacebookSDKPlugin"; + + private static GameObject facebookGameObject; + + internal enum IfNotExist + { + AddNew, + ReturnNull + } + + private static GameObject FacebookGameObject + { + get + { + if (facebookGameObject == null) + { + facebookGameObject = new GameObject(GameObjectName); + } + + return facebookGameObject; + } + } + + /** + * Gets one and only one component. Lazy creates one if it doesn't exist + */ + public static T GetComponent(IfNotExist ifNotExist = IfNotExist.AddNew) where T : MonoBehaviour + { + var facebookGameObject = FacebookGameObject; + + T component = facebookGameObject.GetComponent(); + if (component == null && ifNotExist == IfNotExist.AddNew) + { + component = facebookGameObject.AddComponent(); + } + + return component; + } + + /** + * Creates a new component on the Facebook object regardless if there is already one + */ + public static T AddComponent() where T : MonoBehaviour + { + return FacebookGameObject.AddComponent(); + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/ComponentFactory.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/ComponentFactory.cs.meta new file mode 100644 index 000000000..4f822742a --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/ComponentFactory.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d7083e38c488348148cfe0d23b48599a +timeCreated: 1437500989 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Constants.cs b/Facebook.Unity/Assets/Facebook/Scripts/Constants.cs new file mode 100644 index 000000000..0994f9e8a --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Constants.cs @@ -0,0 +1,87 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + internal static class Constants + { + // Callback keys + public const string CallbackIdKey = "callback_id"; + public const string AccessTokenKey = "access_token"; + public const string UrlKey = "url"; + public const string RefKey = "ref"; + public const string ExtrasKey = "extras"; + public const string TargetUrlKey = "target_url"; + public const string CancelledKey = "cancelled"; + public const string ErrorKey = "error"; + + // Callback Method Names + public const string OnPayCompleteMethodName = "OnPayComplete"; + public const string OnShareCompleteMethodName = "OnShareLinkComplete"; + public const string OnAppRequestsCompleteMethodName = "OnAppRequestsComplete"; + public const string OnGroupCreateCompleteMethodName = "OnGroupCreateComplete"; + public const string OnJoinGroupCompleteMethodName = "OnJoinGroupComplete"; + + // Graph API + public const string GraphUrl = "https://graph.facebook.com"; + + // Permission Strings + public const string UserLikesPermission = "user_likes"; + public const string EmailPermission = "email"; + public const string PublishActionsPermission = "publish_actions"; + public const string PublishPagesPermission = "publish_pages"; + + public static bool IsMobile + { + get + { +#if UNITY_ANDROID || UNITY_IOS + return true; +#else + return false; +#endif + } + } + + public static bool IsEditor + { + get + { +#if UNITY_EDITOR + return true; +#else + return false; +#endif + } + } + + public static bool IsWeb + { + get + { +#if UNITY_WEBPLAYER || UNITY_WEBGL + return true; +#else + return false; +#endif + } + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Constants.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Constants.cs.meta new file mode 100644 index 000000000..53aec6701 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Constants.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a77c98a28d47d42e89bd59c4a5b9b7cd +timeCreated: 1437607402 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/FB.cs b/Facebook.Unity/Assets/Facebook/Scripts/FB.cs new file mode 100644 index 000000000..4243d384b --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/FB.cs @@ -0,0 +1,776 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using System; + using System.Collections; + using System.Collections.Generic; + using Facebook.Unity.Canvas; + using Facebook.Unity.Editor; + using Facebook.Unity.Mobile; + using Facebook.Unity.Mobile.Android; + using Facebook.Unity.Mobile.IOS; + using UnityEngine; + + /// + /// Static class for exposing the facebook integration + /// + public sealed class FB : ScriptableObject + { + private static InitDelegate onInitComplete; + private static HideUnityDelegate onHideUnity; + + private static FacebookGameObject facebook; + private static string authResponse; + private static bool isInitCalled = false; + private static string appId; + private static bool cookie; + private static bool logging; + private static bool status; + private static bool xfbml; + private static bool frictionlessRequests; + + /// + /// Gets the app identifier. AppId might be different from FBSettings.AppId + /// if using the programmatic version of FB.Init() + /// + /// The app identifier. + public static string AppId + { + get + { + return appId; + } + } + + /// + /// Gets a value indicating a user logged in. + /// + /// true if is logged in; otherwise, false. + public static bool IsLoggedIn + { + get + { + return (facebook != null) && FacebookImpl.LoggedIn; + } + } + + /// + /// Gets a value indicating is the SDK is initialized. + /// + /// true if is initialized; otherwise, false. + public static bool IsInitialized + { + get + { + return (facebook != null) && facebook.Initialized; + } + } + + // If the player has set the limitEventUsage flag to YES, your app will continue + // to send this data to Facebook, but Facebook will not use the data to serve + // targeted ads. Facebook may continue to use the information for other purposes, + // including frequency capping, conversion events, estimating the number of unique + // users, security and fraud detection, and debugging. + public static bool LimitAppEventUsage + { + get + { + return (facebook != null) && facebook.Facebook.LimitEventUsage; + } + + set + { + if (facebook != null) + { + facebook.Facebook.LimitEventUsage = value; + } + } + } + + internal static IFacebook FacebookImpl + { + get + { + if (facebook == null) + { + throw new NullReferenceException("Facebook object is not yet loaded. Did you call FB.Init()?"); + } + + return facebook.Facebook; + } + } + + /// + /// This is the preferred way to call FB.Init(). It will take the facebook app id specified in your "Facebook" + /// => "Edit Settings" menu when it is called. + /// + /// + /// Delegate is called when FB.Init() finished initializing everything. By passing in a delegate you can find + /// out when you can safely call the other methods. + /// + /// A delegate to invoke when unity is hidden. + /// Auth response. + public static void Init(InitDelegate onInitComplete = null, HideUnityDelegate onHideUnity = null, string authResponse = null) + { + Init( + FacebookSettings.AppId, + FacebookSettings.Cookie, + FacebookSettings.Logging, + FacebookSettings.Status, + FacebookSettings.Xfbml, + FacebookSettings.FrictionlessRequests, + authResponse, + onHideUnity, + onInitComplete); + } + + /// + /// If you need a more programmatic way to set the facebook app id and other setting call this function. + /// Useful for a build pipeline that requires no human input. + /// + /// App identifier. + /// If set to true cookie. + /// If set to true logging. + /// If set to true status. + /// If set to true xfbml. + /// If set to true frictionless requests. + /// Auth response. + /// + /// A delegate to invoke when unity is hidden. + /// + /// + /// Delegate is called when FB.Init() finished initializing everything. By passing in a delegate you can find + /// out when you can safely call the other methods. + /// + public static void Init( + string appId, + bool cookie = true, + bool logging = true, + bool status = true, + bool xfbml = false, + bool frictionlessRequests = true, + string authResponse = null, + HideUnityDelegate onHideUnity = null, + InitDelegate onInitComplete = null) + { + if (string.IsNullOrEmpty(appId)) + { + throw new ArgumentException("appId cannot be null or empty!"); + } + + FB.appId = appId; + FB.cookie = cookie; + FB.logging = logging; + FB.status = status; + FB.xfbml = xfbml; + FB.frictionlessRequests = frictionlessRequests; + FB.authResponse = authResponse; + FB.onInitComplete = onInitComplete; + FB.onHideUnity = onHideUnity; + + if (!isInitCalled) + { + FB.LogVersion(); + + #if UNITY_EDITOR + ComponentFactory.GetComponent(); + #elif UNITY_WEBPLAYER || UNITY_WEBGL + ComponentFactory.GetComponent(); + #elif UNITY_IOS + ComponentFactory.GetComponent(); + #elif UNITY_ANDROID + ComponentFactory.GetComponent(); + #else + throw new NotImplementedException("Facebook API does not yet support this platform"); + #endif + isInitCalled = true; + return; + } + + FacebookLogger.Warn("FB.Init() has already been called. You only need to call this once and only once."); + + // Init again if possible just in case something bad actually happened. + if (FacebookImpl != null) + { + OnDllLoaded(); + } + } + + /// + /// Logs the user in with the requested publish permissions. + /// + /// A list of requested permissions. + /// Callback to be called when request completes. + public static void LogInWithPublishPermissions( + IEnumerable permissions = null, + FacebookDelegate callback = null) + { + FacebookImpl.LogInWithPublishPermissions(permissions, callback); + } + + /// + /// Logs the user in with the requested read permissions + /// + /// A list of requested permissions. + /// Callback to be called when request completes. + public static void LogInWithReadPermissions( + IEnumerable permissions = null, + FacebookDelegate callback = null) + { + FacebookImpl.LogInWithReadPermissions(permissions, callback); + } + + /// + /// Logs out the current user. + /// + public static void LogOut() + { + FacebookImpl.LogOut(); + } + + /// + /// Apps the request. + /// + /// The request string the recipient will see, maximum length 60 characters. + /// Request action type for structured request. + /// + /// Open Graph object ID for structured request. + /// Note the type of object should belong to this app. + /// + /// A list of Facebook IDs to which to send the request. + /// + /// Additional data stored with the request on Facebook, + /// and handed back to the app when it reads the request back out. + /// Maximum length 255 characters. + /// The title for the platform multi-friend selector dialog. Max length 50 characters.. + /// A callback for when the request completes. + public static void AppRequest( + string message, + OGActionType actionType, + string objectId, + IEnumerable to, + string data = "", + string title = "", + FacebookDelegate callback = null) + { + FacebookImpl.AppRequest(message, actionType, objectId, to, null, null, null, data, title, callback); + } + + /// + /// Apps the request. + /// + /// The request string the recipient will see, maximum length 60 characters. + /// Request action type for structured request. + /// + /// Open Graph object ID for structured request. + /// Note the type of object should belong to this app. + /// + /// + /// The configuration of the platform multi-friend selector. + /// It should be a List of filter strings. + /// + /// + /// A list of Facebook IDs to exclude from the platform multi-friend selector dialog. + /// This list is currently not supported for mobile devices + /// + /// + /// Platform-dependent The maximum number of recipients the sender should be able to + /// choose in the platform multi-friend selector dialog. + /// Only guaranteed to work in Unity Web Player app. + /// + /// + /// Additional data stored with the request on Facebook, and handed + /// back to the app when it reads the request back out. + /// Maximum length 255 characters. + /// + /// + /// The title for the platform multi-friend selector dialog. Max length 50 characters. + /// + /// A callback for when the request completes. + public static void AppRequest( + string message, + OGActionType actionType, + string objectId, + IEnumerable filters = null, + IEnumerable excludeIds = null, + int? maxRecipients = null, + string data = "", + string title = "", + FacebookDelegate callback = null) + { + FacebookImpl.AppRequest(message, actionType, objectId, null, filters, excludeIds, maxRecipients, data, title, callback); + } + + /// + /// Apps the request. + /// + /// The request string the recipient will see, maximum length 60 characters. + /// A list of Facebook IDs to which to send the request. + /// + /// The configuration of the platform multi-friend selector. + /// It should be a List of filter strings. + /// + /// + /// A list of Facebook IDs to exclude from the platform multi-friend selector dialog. + /// This list is currently not supported for mobile devices + /// + /// + /// Platform-dependent The maximum number of recipients the sender should be able to + /// choose in the platform multi-friend selector dialog. + /// Only guaranteed to work in Unity Web Player app. + /// + /// + /// Additional data stored with the request on Facebook, and handed + /// back to the app when it reads the request back out. + /// Maximum length 255 characters. + /// + /// + /// The title for the platform multi-friend selector dialog. Max length 50 characters. + /// + /// A callback for when the request completes. + public static void AppRequest( + string message, + IEnumerable to = null, + IEnumerable filters = null, + IEnumerable excludeIds = null, + int? maxRecipients = null, + string data = "", + string title = "", + FacebookDelegate callback = null) + { + FacebookImpl.AppRequest(message, null, null, to, filters, excludeIds, maxRecipients, data, title, callback); + } + + /// + /// Opens a share dialog for sharing a link. + /// + /// The URL or the link to share. + /// The title to display for this link.. + /// + /// The description of the link. If not specified, this field is automatically populated by + /// information scraped from the link, typically the title of the page. + /// + /// The URL of a picture to attach to this content. + /// A callback for when the request completes. + public static void ShareLink( + Uri contentURL = null, + string contentTitle = "", + string contentDescription = "", + Uri photoURL = null, + FacebookDelegate callback = null) + { + FacebookImpl.ShareLink( + contentURL, + contentTitle, + contentDescription, + photoURL, + callback); + } + + /// + /// Legacy feed share. Only use this dialog if you need the legacy parameters otherwiese use + /// . + /// + /// + /// The ID of the profile that this story will be published to. + /// If this is unspecified, it defaults to the value of from. + /// The ID must be a friend who also uses your app. + /// + /// The link attached to this post. + /// The name of the link attachment. + /// + /// The caption of the link (appears beneath the link name). + /// If not specified, this field is automatically populated + /// with the URL of the link. + /// + /// + /// The description of the link (appears beneath the link caption). + /// If not specified, this field is automatically populated by information + /// scraped from the link, typically the title of the page. + /// + /// + /// The URL of a picture attached to this post. + /// The picture must be at least 200px by 200px. + /// See our documentation on sharing best practices for more information on sizes. + /// + /// + /// The URL of a media file (either SWF or MP3) attached to this post. + /// If SWF, you must also specify picture to provide a thumbnail for the video. + /// + /// The callback to use upon completion. + public static void FeedShare( + string toId = "", + Uri link = null, + string linkName = "", + string linkCaption = "", + string linkDescription = "", + Uri picture = null, + string mediaSource = "", + FacebookDelegate callback = null) + { + FacebookImpl.FeedShare( + toId, + link, + linkName, + linkCaption, + linkDescription, + picture, + mediaSource, + callback); + } + + /// + /// Makes a call to the Facebook Graph API. + /// + /// + /// The Graph API endpoint to call. + /// You may prefix this with a version string to call a particular version of the API. + /// + /// The HTTP method to use in the call. + /// The callback to use upon completion. + /// The key/value pairs to be passed to the endpoint as arguments. + public static void API( + string query, + HttpMethod method, + FacebookDelegate callback = null, + IDictionary formData = null) + { + FacebookImpl.API(query, method, formData, callback); + } + + /// + /// Makes a call to the Facebook Graph API. + /// + /// + /// The Graph API endpoint to call. + /// You may prefix this with a version string to call a particular version of the API. + /// + /// The HTTP method to use in the call. + /// The callback to use upon completion. + /// Form data for the request. + public static void API( + string query, + HttpMethod method, + FacebookDelegate callback, + WWWForm formData) + { + FacebookImpl.API(query, method, formData, callback); + } + + /// + /// Sends an app activation event to Facebook when your app is activated. + /// + public static void ActivateApp() + { + FacebookImpl.ActivateApp(AppId); + } + + /// + /// Gets the deep link if available. + /// + /// The callback to use upon completion. + public static void GetAppLink( + FacebookDelegate callback) + { + if (callback == null) + { + // No point in fetching the data if there is no callback + return; + } + + FacebookImpl.GetAppLink(callback); + } + + /// + /// Opens a dialog to create a new game group + /// + /// The name of the group you wish to create. + /// A short description of the group's purpose. + /// + /// The privacy of the group. + /// OPEN groups' content is visible to anyone + /// CLOSED groups can be found by anyone but their content is only visible to members + /// SECRET groups can only be found by their members. + /// + /// The callback to use upon completion. + public static void GameGroupCreate( + string name, + string description, + string privacy = "CLOSED", + FacebookDelegate callback = null) + { + FacebookImpl.GameGroupCreate(name, description, privacy, callback); + } + + /// + /// Opens a dialog to join a game group. + /// + /// The group ID of the group to which you'd like to add the user. + /// The callback to use upon completion. + public static void GameGroupJoin( + string id, + FacebookDelegate callback = null) + { + FacebookImpl.GameGroupJoin(id, callback); + } + + /// + /// Logs an app event. + /// + /// The name of the event to log. + /// A number representing some value to be summed when reported. + /// Any parameters needed to describe the event. + public static void LogAppEvent( + string logEvent, + float? valueToSum = null, + Dictionary parameters = null) + { + FacebookImpl.AppEventsLogEvent(logEvent, valueToSum, parameters); + } + + /// + /// Logs the purchase. + /// + /// The amount of currency the user spent. + /// The 3-letter ISO currency code. + /// + /// Any parameters needed to describe the event. + /// Elements included in this dictionary can't be null. + /// + public static void LogPurchase( + float logPurchase, + string currency = null, + Dictionary parameters = null) + { + if (string.IsNullOrEmpty(currency)) + { + currency = "USD"; + } + + FacebookImpl.AppEventsLogPurchase(logPurchase, currency, parameters); + } + + private static void OnDllLoaded() + { + FB.LogVersion(); + FacebookImpl.Init( + appId, + cookie, + logging, + status, + xfbml, + FacebookSettings.ChannelUrl, + authResponse, + frictionlessRequests, + onHideUnity, + onInitComplete); + } + + private static void LogVersion() + { + // If we have initlized we can also get the underlying sdk version + if (facebook != null) + { + FacebookLogger.Info(string.Format( + "Using Unity SDK v{0} with {1}", + FacebookSdkVersion.Build, + FB.FacebookImpl.FacebookSdkVersion)); + } + else + { + FacebookLogger.Info(string.Format("Using Unity SDK v{0}", FacebookSdkVersion.Build)); + } + } + + public sealed class Canvas + { + private static ICanvasFacebook CanvasFacebookImpl + { + get + { + ICanvasFacebook impl = FacebookImpl as ICanvasFacebook; + if (impl == null) + { + throw new InvalidOperationException("Attempt to call Canvas interface on non canvas platform"); + } + + return impl; + } + } + + /// + /// Pay the specified product, action, quantity, quantityMin, quantityMax, requestId, pricepointId, + /// testCurrency and callback. + /// + /// The URL of your og:product object that the user is looking to purchase. + /// Should always be purchaseitem. + /// + /// The amount of this item the user is looking to purchase - typically used when implementing a virtual currency purchase. + /// + /// + /// The minimum quantity of the item the user is able to purchase. + /// This parameter is important when handling price jumping to maximize the efficiency of the transaction. + /// + /// + /// The maximum quantity of the item the user is able to purchase. + /// This parameter is important when handling price jumping to maximize the efficiency of the transaction. + /// + /// + /// The developer defined unique identifier for this transaction, which becomes + /// attached to the payment within the Graph API. + /// + /// + /// Used to shortcut a mobile payer directly to the + /// mobile purchase flow at a given price point. + /// + /// + /// This parameter can be used during debugging and testing your implementation to force the dialog to + /// use a specific currency rather than the current user's preferred currency. This allows you to + /// rapidly prototype your payment experience for different currencies without having to repeatedly + /// change your personal currency preference settings. This parameter is only available for admins, + /// developers and testers associated with the app, in order to minimize the security risk of a + /// malicious JavaScript injection. Provide the 3 letter currency code of the intended forced currency. + /// + /// The callback to use upon completion. + public static void Pay( + string product, + string action = "purchaseitem", + int quantity = 1, + int? quantityMin = null, + int? quantityMax = null, + string requestId = null, + string pricepointId = null, + string testCurrency = null, + FacebookDelegate callback = null) + { + CanvasFacebookImpl.Pay( + product, + action, + quantity, + quantityMin, + quantityMax, + requestId, + pricepointId, + testCurrency, + callback); + } + } + + /// + /// A class containing the settings specific to the supported mobile platforms. + /// + public sealed class Mobile + { + /// + /// Gets or sets the share dialog mode. + /// + /// The share dialog mode. + public static ShareDialogMode ShareDialogMode + { + get + { + return Mobile.MobileFacebookImpl.ShareDialogMode; + } + + set + { + Mobile.MobileFacebookImpl.ShareDialogMode = value; + } + } + + private static IMobileFacebook MobileFacebookImpl + { + get + { + IMobileFacebook impl = FacebookImpl as IMobileFacebook; + if (impl == null) + { + throw new InvalidOperationException("Attempt to call Mobile interface on non mobile platform"); + } + + return impl; + } + } + + /// + /// Show the app invite dialog. + /// + /// + /// App Link for what should be opened when the recipient clicks on the + /// install/play button on the app invite page. + /// + /// A url to an image to be used in the invite. + /// A callback for when the dialog completes + public static void AppInvite( + Uri appLinkUrl, + Uri previewImageUrl = null, + FacebookDelegate callback = null) + { + MobileFacebookImpl.AppInvite(appLinkUrl, previewImageUrl, callback); + } + + /// + /// Fetchs the deferred app link data. + /// + /// A callback for when the call is complete. + public static void FetchDeferredAppLinkData( + FacebookDelegate callback = null) + { + if (callback == null) + { + // No point in fetching the data if there is no callback + return; + } + + Mobile.MobileFacebookImpl.FetchDeferredAppLink(callback); + } + } + + public sealed class Android + { + /// + /// Gets the key hash. + /// + /// The key hash. + public static string KeyHash + { + get + { + var androidFacebook = FacebookImpl as AndroidFacebook; + return (androidFacebook != null) ? androidFacebook.KeyHash : string.Empty; + } + } + } + + internal abstract class CompiledFacebookLoader : MonoBehaviour + { + protected abstract FacebookGameObject FBGameObject { get; } + + public void Start() + { + FB.facebook = this.FBGameObject; + FB.OnDllLoaded(); + MonoBehaviour.Destroy(this); + } + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/FB.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/FB.cs.meta new file mode 100644 index 000000000..8c2e664a6 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/FB.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3f8e8bd7df50efd4dbcc84dac4e57de3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/FacebookBase.cs b/Facebook.Unity/Assets/Facebook/Scripts/FacebookBase.cs new file mode 100644 index 000000000..f693c4cfe --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/FacebookBase.cs @@ -0,0 +1,280 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using System; + using System.Collections.Generic; + using UnityEngine; + + internal abstract class FacebookBase : IFacebookImplementation + { + private InitDelegate onInitCompleteDelegate; + private HideUnityDelegate onHideUnityDelegate; + + protected FacebookBase(CallbackManager callbackManager) + { + this.CallbackManager = callbackManager; + } + + public abstract bool LimitEventUsage { get; set; } + + public abstract string FacebookSdkVersion { get; } + + public bool LoggedIn + { + get + { + return AccessToken.CurrentAccessToken != null; + } + } + + protected CallbackManager CallbackManager { get; private set; } + + public virtual void Init( + string appId, + bool cookie, + bool logging, + bool status, + bool xfbml, + string channelUrl, + string authResponse, + bool frictionlessRequests, + HideUnityDelegate hideUnityDelegate, + InitDelegate onInitComplete) + { + this.onHideUnityDelegate = hideUnityDelegate; + this.onInitCompleteDelegate = onInitComplete; + } + + public abstract void LogInWithPublishPermissions( + IEnumerable scope, + FacebookDelegate callback); + + public abstract void LogInWithReadPermissions( + IEnumerable scope, + FacebookDelegate callback); + + public virtual void LogOut() + { + AccessToken.CurrentAccessToken = null; + } + + public void AppRequest( + string message, + IEnumerable to = null, + IEnumerable filters = null, + IEnumerable excludeIds = null, + int? maxRecipients = null, + string data = "", + string title = "", + FacebookDelegate callback = null) + { + this.AppRequest(message, null, null, to, filters, excludeIds, maxRecipients, data, title, callback); + } + + public abstract void AppRequest( + string message, + OGActionType? actionType, + string objectId, + IEnumerable to, + IEnumerable filters, + IEnumerable excludeIds, + int? maxRecipients, + string data, + string title, + FacebookDelegate callback); + + public abstract void ShareLink( + Uri contentURL, + string contentTitle, + string contentDescription, + Uri photoURL, + FacebookDelegate callback); + + public abstract void FeedShare( + string toId, + Uri link, + string linkName, + string linkCaption, + string linkDescription, + Uri picture, + string mediaSource, + FacebookDelegate callback); + + public void API( + string query, + HttpMethod method, + IDictionary formData, + FacebookDelegate callback) + { + IDictionary inputFormData; + + // Copy the formData by value so it's not vulnerable to scene changes and object deletions + inputFormData = (formData != null) ? this.CopyByValue(formData) : new Dictionary(); + if (!inputFormData.ContainsKey(Constants.AccessTokenKey) && !query.Contains("access_token=")) + { + inputFormData[Constants.AccessTokenKey] = + FB.IsLoggedIn ? AccessToken.CurrentAccessToken.TokenString : string.Empty; + } + + AsyncRequestString.Request(this.GetGraphUrl(query), method, inputFormData, callback); + } + + public void API( + string query, + HttpMethod method, + WWWForm formData, + FacebookDelegate callback) + { + if (formData == null) + { + formData = new WWWForm(); + } + + string tokenString = (AccessToken.CurrentAccessToken != null) ? + AccessToken.CurrentAccessToken.TokenString : string.Empty; + formData.AddField( + Constants.AccessTokenKey, + tokenString); + + AsyncRequestString.Request(this.GetGraphUrl(query), method, formData, callback); + } + + public abstract void GameGroupCreate( + string name, + string description, + string privacy, + FacebookDelegate callback); + + public abstract void GameGroupJoin( + string id, + FacebookDelegate callback); + + public abstract void ActivateApp(string appId = null); + + public abstract void GetAppLink(FacebookDelegate callback); + + public abstract void AppEventsLogEvent( + string logEvent, + float? valueToSum, + Dictionary parameters); + + public abstract void AppEventsLogPurchase( + float logPurchase, + string currency, + Dictionary parameters); + + public virtual void OnHideUnity(bool isGameShown) + { + if (this.onHideUnityDelegate != null) + { + this.onHideUnityDelegate(isGameShown); + } + } + + public virtual void OnInitComplete(string message) + { + this.OnLoginComplete(message); + if (this.onInitCompleteDelegate != null) + { + this.onInitCompleteDelegate(); + } + } + + public abstract void OnLoginComplete(string message); + + public void OnLogoutComplete(string message) + { + AccessToken.CurrentAccessToken = null; + } + + public abstract void OnGetAppLinkComplete(string message); + + public abstract void OnGroupCreateComplete(string message); + + public abstract void OnGroupJoinComplete(string message); + + public abstract void OnAppRequestsComplete(string message); + + public abstract void OnShareLinkComplete(string message); + + protected void ValidateAppRequestArgs( + string message, + OGActionType? actionType, + string objectId, + IEnumerable to = null, + IEnumerable filters = null, + IEnumerable excludeIds = null, + int? maxRecipients = null, + string data = "", + string title = "", + FacebookDelegate callback = null) + { + if (string.IsNullOrEmpty(message)) + { + throw new ArgumentNullException("message", "message cannot be null or empty!"); + } + + if (!string.IsNullOrEmpty(objectId) && !(actionType == OGActionType.ASKFOR || actionType == OGActionType.SEND)) + { + throw new ArgumentNullException("objectId", "Object ID must be set if and only if action type is SEND or ASKFOR"); + } + + if (actionType == null && !string.IsNullOrEmpty(objectId)) + { + throw new ArgumentNullException("actionType", "You cannot provide an objectId without an actionType"); + } + } + + protected void OnAuthResponse(LoginResult result) + { + // If the login is cancelled we won't have a access token. + // Don't overwrite a valid token + if (result.AccessToken != null) + { + AccessToken.CurrentAccessToken = result.AccessToken; + } + + this.CallbackManager.OnFacebookResponse(result); + } + + private IDictionary CopyByValue(IDictionary data) + { + var newData = new Dictionary(data.Count); + foreach (KeyValuePair kvp in data) + { + newData[kvp.Key] = string.Copy(kvp.Value); + } + + return newData; + } + + private string GetGraphUrl(string query) + { + if (!query.StartsWith("/")) + { + query = "/" + query; + } + + return Constants.GraphUrl + query; + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/FacebookBase.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/FacebookBase.cs.meta new file mode 100644 index 000000000..2262fdd0f --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/FacebookBase.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 697ab9361fa544b56adfb6032c999cc7 +timeCreated: 1438126101 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/FacebookGameObject.cs b/Facebook.Unity/Assets/Facebook/Scripts/FacebookGameObject.cs new file mode 100644 index 000000000..d15a1bdb3 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/FacebookGameObject.cs @@ -0,0 +1,95 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using System; + using System.Collections; + using System.Collections.Generic; + using UnityEngine; + + public delegate void InitDelegate(); + + public delegate void FacebookDelegate(T result) where T : IResult; + + public delegate void HideUnityDelegate(bool isUnityShown); + + internal abstract class FacebookGameObject : MonoBehaviour, IFacebookCallbackHandler + { + public IFacebookImplementation Facebook { get; set; } + + public bool Initialized { get; private set; } + + public void Awake() + { + MonoBehaviour.DontDestroyOnLoad(this); + AccessToken.CurrentAccessToken = null; + + // run whatever else needs to be setup + this.OnAwake(); + } + + public void OnInitComplete(string message) + { + this.Facebook.OnInitComplete(message); + this.Initialized = true; + } + + public void OnLoginComplete(string message) + { + this.Facebook.OnLoginComplete(message); + } + + public void OnLogoutComplete(string message) + { + this.Facebook.OnLogoutComplete(message); + } + + public void OnGetAppLinkComplete(string message) + { + this.Facebook.OnGetAppLinkComplete(message); + } + + public void OnGroupCreateComplete(string message) + { + this.Facebook.OnGroupCreateComplete(message); + } + + public void OnGroupJoinComplete(string message) + { + this.Facebook.OnGroupJoinComplete(message); + } + + public void OnAppRequestsComplete(string message) + { + this.Facebook.OnAppRequestsComplete(message); + } + + public void OnShareLinkComplete(string message) + { + this.Facebook.OnShareLinkComplete(message); + } + + // use this to call the rest of the Awake function + protected virtual void OnAwake() + { + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/FacebookGameObject.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/FacebookGameObject.cs.meta new file mode 100644 index 000000000..7d4f598c6 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/FacebookGameObject.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 18b79731917a04dcea66cd9433b05ffa +timeCreated: 1438298352 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/FacebookSdkVersion.cs b/Facebook.Unity/Assets/Facebook/Scripts/FacebookSdkVersion.cs new file mode 100644 index 000000000..0d6846667 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/FacebookSdkVersion.cs @@ -0,0 +1,38 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using System; + + /// + /// Facebook sdk version. + /// + public class FacebookSdkVersion + { + public static string Build + { + get + { + return "7.1.0"; + } + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/FacebookSdkVersion.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/FacebookSdkVersion.cs.meta new file mode 100644 index 000000000..e1c47199e --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/FacebookSdkVersion.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 30b6dcc2972864be194f2fce06358ff3 +timeCreated: 1435096237 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/FacebookSettings.cs b/Facebook.Unity/Assets/Facebook/Scripts/FacebookSettings.cs new file mode 100644 index 000000000..f45ffd477 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/FacebookSettings.cs @@ -0,0 +1,398 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using System.Collections.Generic; + using System.IO; + using System.Linq; + #if UNITY_EDITOR + using UnityEditor; + #endif + using UnityEngine; + + #if UNITY_EDITOR + [InitializeOnLoad] + #endif + public class FacebookSettings : ScriptableObject + { + private const string FacebookSettingsAssetName = "FacebookSettings"; + private const string FacebookSettingsPath = "Facebook/Resources"; + private const string FacebookSettingsAssetExtension = ".asset"; + + private static FacebookSettings instance; + + [SerializeField] + private int selectedAppIndex = 0; + [SerializeField] + private List appIds = new List { "0" }; + [SerializeField] + private List appLabels = new List { "App Name" }; + [SerializeField] + private bool cookie = true; + [SerializeField] + private bool logging = true; + [SerializeField] + private bool status = true; + [SerializeField] + private bool xfbml = false; + [SerializeField] + private bool frictionlessRequests = true; + [SerializeField] + private string iosURLSuffix = string.Empty; + [SerializeField] + private List appLinkSchemes = new List() { new UrlSchemes() }; + + public static int SelectedAppIndex + { + get + { + return Instance.selectedAppIndex; + } + + set + { + if (Instance.selectedAppIndex != value) + { + Instance.selectedAppIndex = value; + FacebookSettings.DirtyEditor(); + } + } + } + + public static List AppIds + { + get + { + return Instance.appIds; + } + + set + { + if (Instance.appIds != value) + { + Instance.appIds = value; + DirtyEditor(); + } + } + } + + public static List AppLabels + { + get + { + return Instance.appLabels; + } + + set + { + if (Instance.appLabels != value) + { + Instance.appLabels = value; + DirtyEditor(); + } + } + } + + public static string AppId + { + get + { + return AppIds[SelectedAppIndex]; + } + } + + public static bool IsValidAppId + { + get + { + return FacebookSettings.AppId != null + && FacebookSettings.AppId.Length > 0 + && !FacebookSettings.AppId.Equals("0"); + } + } + + public static bool Cookie + { + get + { + return Instance.cookie; + } + + set + { + if (Instance.cookie != value) + { + Instance.cookie = value; + DirtyEditor(); + } + } + } + + public static bool Logging + { + get + { + return Instance.logging; + } + + set + { + if (Instance.logging != value) + { + Instance.logging = value; + DirtyEditor(); + } + } + } + + public static bool Status + { + get + { + return Instance.status; + } + + set + { + if (Instance.status != value) + { + Instance.status = value; + DirtyEditor(); + } + } + } + + public static bool Xfbml + { + get + { + return Instance.xfbml; + } + + set + { + if (Instance.xfbml != value) + { + Instance.xfbml = value; + DirtyEditor(); + } + } + } + + public static string IosURLSuffix + { + get + { + return Instance.iosURLSuffix; + } + + set + { + if (Instance.iosURLSuffix != value) + { + Instance.iosURLSuffix = value; + DirtyEditor(); + } + } + } + + public static string ChannelUrl + { + get { return "/channel.html"; } + } + + public static bool FrictionlessRequests + { + get + { + return Instance.frictionlessRequests; + } + + set + { + if (Instance.frictionlessRequests != value) + { + Instance.frictionlessRequests = value; + DirtyEditor(); + } + } + } + + /// + /// Gets or sets the app link schemes. + /// + /// A list of app link schemese for each app + public static List AppLinkSchemes + { + get + { + return Instance.appLinkSchemes; + } + + set + { + if (Instance.appLinkSchemes != value) + { + Instance.appLinkSchemes = value; + DirtyEditor(); + } + } + } + +#if UNITY_EDITOR + + private string testFacebookId = ""; + private string testAccessToken = ""; + + public static string TestFacebookId + { + get { return Instance.testFacebookId; } + set + { + if (Instance.testFacebookId != value) + { + Instance.testFacebookId = value; + DirtyEditor(); + } + } + } + + public static string TestAccessToken + { + get { return Instance.testAccessToken; } + set + { + if (Instance.testAccessToken != value) + { + Instance.testAccessToken = value; + DirtyEditor(); + } + } + } +#endif + + private static FacebookSettings Instance + { + get + { + if (instance == null) + { + instance = Resources.Load(FacebookSettingsAssetName) as FacebookSettings; + if (instance == null) + { + // If not found, autocreate the asset object. + instance = ScriptableObject.CreateInstance(); + #if UNITY_EDITOR + string properPath = Path.Combine(Application.dataPath, FacebookSettingsPath); + if (!Directory.Exists(properPath)) + { + AssetDatabase.CreateFolder("Assets/Facebook", "Resources"); + } + + string fullPath = Path.Combine(Path.Combine("Assets", FacebookSettingsPath), + FacebookSettingsAssetName + FacebookSettingsAssetExtension + ); + AssetDatabase.CreateAsset(instance, fullPath); + #endif + } + } + + return instance; + } + } + + public static void SettingsChanged() + { + FacebookSettings.DirtyEditor(); + } + + #if UNITY_EDITOR + [MenuItem("Facebook/Edit Settings")] + public static void Edit() + { + Selection.activeObject = Instance; + } + + [MenuItem("Facebook/Developers Page")] + public static void OpenAppPage() + { + string url = "https://developers.facebook.com/apps/"; + if (FacebookSettings.AppIds[FacebookSettings.SelectedAppIndex] != "0") + url += FacebookSettings.AppIds[FacebookSettings.SelectedAppIndex]; + Application.OpenURL(url); + } + + [MenuItem("Facebook/SDK Documentation")] + public static void OpenDocumentation() + { + string url = "https://developers.facebook.com/docs/unity/"; + Application.OpenURL(url); + } + + [MenuItem("Facebook/SDK Facebook Group")] + public static void OpenFacebookGroup() + { + string url = "https://www.facebook.com/groups/491736600899443/"; + Application.OpenURL(url); + } + + [MenuItem("Facebook/Report a SDK Bug")] + public static void ReportABug() + { + string url = "https://developers.facebook.com/bugs"; + Application.OpenURL(url); + } + #endif + + private static void DirtyEditor() + { +#if UNITY_EDITOR + EditorUtility.SetDirty(Instance); +#endif + } + + // Unity doesn't seralize lists of lists so create a serializable type to wrapp the list for use. + [System.Serializable] + public class UrlSchemes + { + [SerializeField] + private List list; + + public UrlSchemes(List schemes = null) + { + this.list = schemes == null ? new List() : schemes; + } + + public List Schemes + { + get + { + return this.list; + } + + set + { + this.list = value; + } + } + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/FacebookSettings.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/FacebookSettings.cs.meta new file mode 100644 index 000000000..85cdce1f1 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/FacebookSettings.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 25d16bd96ce334bc4b521072c4441caa +timeCreated: 1438017243 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/IFacebook.cs b/Facebook.Unity/Assets/Facebook/Scripts/IFacebook.cs new file mode 100644 index 000000000..794eda686 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/IFacebook.cs @@ -0,0 +1,133 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using System; + using System.Collections.Generic; + using UnityEngine; + + internal interface IFacebook + { + bool LoggedIn { get; } + + bool LimitEventUsage { get; set; } + + string FacebookSdkVersion { get; } + + void Init( + string appId, + bool cookie, + bool logging, + bool status, + bool xfbml, + string channelUrl, + string authResponse, + bool frictionlessRequests, + HideUnityDelegate hideUnityDelegate, + InitDelegate onInitComplete); + + void LogInWithPublishPermissions( + IEnumerable permissions, + FacebookDelegate callback); + + void LogInWithReadPermissions( + IEnumerable permissions, + FacebookDelegate callback); + + void LogOut(); + + [Obsolete] + void AppRequest( + string message, + IEnumerable to, + IEnumerable filters, + IEnumerable excludeIds, + int? maxRecipients, + string data, + string title, + FacebookDelegate callback); + + void AppRequest( + string message, + OGActionType? actionType, + string objectId, + IEnumerable to, + IEnumerable filters, + IEnumerable excludeIds, + int? maxRecipients, + string data, + string title, + FacebookDelegate callback); + + void ShareLink( + Uri contentURL, + string contentTitle, + string contentDescription, + Uri photoURL, + FacebookDelegate callback); + + void FeedShare( + string toId, + Uri link, + string linkName, + string linkCaption, + string linkDescription, + Uri picture, + string mediaSource, + FacebookDelegate callback); + + void GameGroupCreate( + string name, + string description, + string privacy, + FacebookDelegate callback); + + void GameGroupJoin( + string id, + FacebookDelegate callback); + + void API( + string query, + HttpMethod method, + IDictionary formData, + FacebookDelegate callback); + + void API( + string query, + HttpMethod method, + WWWForm formData, + FacebookDelegate callback); + + void ActivateApp(string appId = null); + + void GetAppLink(FacebookDelegate callback); + + void AppEventsLogEvent( + string logEvent, + float? valueToSum, + Dictionary parameters); + + void AppEventsLogPurchase( + float logPurchase, + string currency, + Dictionary parameters); + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/IFacebook.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/IFacebook.cs.meta new file mode 100644 index 000000000..6379c988a --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/IFacebook.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e35d2df124187461d84f9446833bbaa5 +timeCreated: 1438126101 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/IFacebookCallbackHandler.cs b/Facebook.Unity/Assets/Facebook/Scripts/IFacebookCallbackHandler.cs new file mode 100644 index 000000000..a51b82ed4 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/IFacebookCallbackHandler.cs @@ -0,0 +1,41 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + internal interface IFacebookCallbackHandler + { + void OnInitComplete(string message); + + void OnLoginComplete(string message); + + void OnLogoutComplete(string message); + + void OnGetAppLinkComplete(string message); + + void OnGroupCreateComplete(string message); + + void OnGroupJoinComplete(string message); + + void OnAppRequestsComplete(string message); + + void OnShareLinkComplete(string message); + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/IFacebookCallbackHandler.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/IFacebookCallbackHandler.cs.meta new file mode 100644 index 000000000..aa6bd540d --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/IFacebookCallbackHandler.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0855bf05bb48e4fb3b52fbe7639c7aed +timeCreated: 1438126101 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/IFacebookImplementation.cs b/Facebook.Unity/Assets/Facebook/Scripts/IFacebookImplementation.cs new file mode 100644 index 000000000..665834d55 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/IFacebookImplementation.cs @@ -0,0 +1,26 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + internal interface IFacebookImplementation : IFacebook, IFacebookCallbackHandler + { + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/IFacebookImplementation.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/IFacebookImplementation.cs.meta new file mode 100644 index 000000000..5b9003e2b --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/IFacebookImplementation.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9f28df8f889c244d7ae1e81c8223921b +timeCreated: 1438126101 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/MethodArguments.cs b/Facebook.Unity/Assets/Facebook/Scripts/MethodArguments.cs new file mode 100644 index 000000000..363275edc --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/MethodArguments.cs @@ -0,0 +1,119 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + internal class MethodArguments + { + private IDictionary arguments = new Dictionary(); + + public MethodArguments() : this(new Dictionary()) + { + } + + public MethodArguments(MethodArguments methodArgs) : this(methodArgs.arguments) + { + } + + private MethodArguments(IDictionary arguments) + { + this.arguments = arguments; + } + + public void AddPrimative(string argumentName, T value) where T : struct + { + this.arguments[argumentName] = value; + } + + public void AddNullablePrimitive(string argumentName, T? nullable) where T : struct + { + if (nullable != null && nullable.HasValue) + { + this.arguments[argumentName] = nullable.Value; + } + } + + public void AddString(string argumentName, string value) + { + if (!string.IsNullOrEmpty(value)) + { + this.arguments[argumentName] = value; + } + } + + public void AddCommaSeparatedList(string argumentName, IEnumerable value) + { + if (value != null) + { + this.arguments[argumentName] = value.ToCommaSeparateList(); + } + } + + public void AddDictionary(string argumentName, IDictionary dict) + { + if (dict != null) + { + this.arguments[argumentName] = MethodArguments.ToStringDict(dict); + } + } + + public void AddList(string argumentName, IEnumerable list) + { + if (list != null) + { + this.arguments[argumentName] = list; + } + } + + public void AddUri(string argumentName, Uri uri) + { + if (uri != null && !string.IsNullOrEmpty(uri.AbsoluteUri)) + { + this.arguments[argumentName] = uri.ToString(); + } + } + + public string ToJsonString() + { + return MiniJSON.Json.Serialize(this.arguments); + } + + private static Dictionary ToStringDict(IDictionary dict) + { + if (dict == null) + { + return null; + } + + var newDict = new Dictionary(); + foreach (KeyValuePair kvp in dict) + { + newDict[kvp.Key] = kvp.Value.ToString(); + } + + return newDict; + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/MethodArguments.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/MethodArguments.cs.meta new file mode 100644 index 000000000..8862caa8b --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/MethodArguments.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4815dca437bd44e2380100c031ef1336 +timeCreated: 1437676825 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/MethodCall.cs b/Facebook.Unity/Assets/Facebook/Scripts/MethodCall.cs new file mode 100644 index 000000000..eb944cc03 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/MethodCall.cs @@ -0,0 +1,45 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using System.Collections; + using System.Collections.Generic; + + internal abstract class MethodCall where T : IResult + { + public MethodCall(FacebookBase facebookImpl, string methodName) + { + this.Parameters = new MethodArguments(); + this.FacebookImpl = facebookImpl; + this.MethodName = methodName; + } + + public string MethodName { get; private set; } + + public FacebookDelegate Callback { protected get; set; } + + protected FacebookBase FacebookImpl { get; set; } + + protected MethodArguments Parameters { get; set; } + + public abstract void Call(MethodArguments args = null); + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/MethodCall.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/MethodCall.cs.meta new file mode 100644 index 000000000..0be0cbb7f --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/MethodCall.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e8dc77d3dfb7f47c3a1a70976e2cb440 +timeCreated: 1436840206 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile.meta b/Facebook.Unity/Assets/Facebook/Scripts/Mobile.meta new file mode 100644 index 000000000..e0968d654 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5f2beb550ad52444396fd9310fe913b8 +folderAsset: yes +timeCreated: 1438298352 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android.meta b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android.meta new file mode 100644 index 000000000..d060aea87 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 180fcb8d2dcbe414ba8d848f82e11ccb +folderAsset: yes +timeCreated: 1438298352 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebook.cs b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebook.cs new file mode 100644 index 000000000..53fd9178e --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebook.cs @@ -0,0 +1,355 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Mobile.Android +{ + using System; + using System.Collections.Generic; + using System.Linq; + + internal sealed class AndroidFacebook : MobileFacebook + { + // This class holds all the of the wrapper methods that we call into + private bool limitEventUsage; + private IAndroidJavaClass facebookJava; + + public AndroidFacebook() : this(new FBJavaClass(), new CallbackManager()) + { + } + + public AndroidFacebook(IAndroidJavaClass facebookJavaClass, CallbackManager callbackManager) + : base(callbackManager) + { + this.KeyHash = string.Empty; + this.facebookJava = facebookJavaClass; + } + + // key Hash used for Android SDK + public string KeyHash { get; private set; } + + public override bool LimitEventUsage + { + get + { + return this.limitEventUsage; + } + + set + { + this.limitEventUsage = value; + this.CallFB("SetLimitEventUsage", value.ToString()); + } + } + + public override string FacebookSdkVersion + { + get + { + string buildVersion = this.facebookJava.CallStatic("GetSdkVersion"); + return string.Format("Facebook.Android.SDK.{0}", buildVersion); + } + } + + public override void Init( + string appId, + bool cookie, + bool logging, + bool status, + bool xfbml, + string channelUrl, + string authResponse, + bool frictionlessRequests, + HideUnityDelegate hideUnityDelegate, + InitDelegate onInitComplete) + { + base.Init( + appId, + cookie, + logging, + status, + xfbml, + channelUrl, + authResponse, + frictionlessRequests, + hideUnityDelegate, + onInitComplete); + + var args = new MethodArguments(); + args.AddString("appId", appId); + args.AddPrimative("cookie", cookie); + args.AddPrimative("logging", logging); + args.AddPrimative("status", status); + args.AddPrimative("xfbml", xfbml); + args.AddString("channelUrl", channelUrl); + args.AddString("authResponse", authResponse); + args.AddPrimative("frictionlessRequests", frictionlessRequests); + var initCall = new JavaMethodCall(this, "Init"); + initCall.Call(args); + this.CallFB( + "SetUserAgentSuffix", + string.Format("Unity.{0}", Facebook.Unity.FacebookSdkVersion.Build)); + } + + public override void LogInWithReadPermissions( + IEnumerable permissions, + FacebookDelegate callback) + { + MethodArguments args = new MethodArguments(); + args.AddCommaSeparatedList("scope", permissions); + var loginCall = new JavaMethodCall(this, "LoginWithReadPermissions"); + loginCall.Callback = callback; + loginCall.Call(args); + } + + public override void LogInWithPublishPermissions( + IEnumerable permissions, + FacebookDelegate callback) + { + MethodArguments args = new MethodArguments(); + args.AddCommaSeparatedList("scope", permissions); + var loginCall = new JavaMethodCall(this, "LoginWithPublishPermissions"); + loginCall.Callback = callback; + loginCall.Call(args); + } + + public override void LogOut() + { + var logoutCall = new JavaMethodCall(this, "Logout"); + logoutCall.Call(); + } + + public override void AppRequest( + string message, + OGActionType? actionType, + string objectId, + IEnumerable to, + IEnumerable filters, + IEnumerable excludeIds, + int? maxRecipients, + string data, + string title, + FacebookDelegate callback) + { + this.ValidateAppRequestArgs( + message, + actionType, + objectId, + to, + filters, + excludeIds, + maxRecipients, + data, + title, + callback); + + MethodArguments args = new MethodArguments(); + args.AddString("message", message); + args.AddNullablePrimitive("action_type", actionType); + args.AddString("object_id", objectId); + args.AddCommaSeparatedList("to", to); + if (filters != null && filters.Any()) + { + string mobileFilter = filters.First() as string; + if (mobileFilter != null) + { + args.AddString("filters", mobileFilter); + } + } + + args.AddNullablePrimitive("max_recipients", maxRecipients); + args.AddString("data", data); + args.AddString("title", title); + var appRequestCall = new JavaMethodCall(this, "AppRequest"); + appRequestCall.Callback = callback; + appRequestCall.Call(args); + } + + public override void AppInvite( + Uri appLinkUrl, + Uri previewImageUrl, + FacebookDelegate callback) + { + MethodArguments args = new MethodArguments(); + args.AddUri("appLinkUrl", appLinkUrl); + args.AddUri("previewImageUrl", previewImageUrl); + var appInviteCall = new JavaMethodCall(this, "AppInvite"); + appInviteCall.Callback = callback; + appInviteCall.Call(args); + } + + public override void ShareLink( + Uri contentURL, + string contentTitle, + string contentDescription, + Uri photoURL, + FacebookDelegate callback) + { + MethodArguments args = new MethodArguments(); + args.AddUri("content_url", contentURL); + args.AddString("content_title", contentTitle); + args.AddString("content_description", contentDescription); + args.AddUri("photo_url", photoURL); + var shareLinkCall = new JavaMethodCall(this, "ShareLink"); + shareLinkCall.Callback = callback; + shareLinkCall.Call(args); + } + + public override void FeedShare( + string toId, + Uri link, + string linkName, + string linkCaption, + string linkDescription, + Uri picture, + string mediaSource, + FacebookDelegate callback) + { + MethodArguments args = new MethodArguments(); + args.AddString("toId", toId); + args.AddUri("link", link); + args.AddString("linkName", linkName); + args.AddString("linkCaption", linkCaption); + args.AddString("linkDescription", linkDescription); + args.AddUri("picture", picture); + args.AddString("mediaSource", mediaSource); + var call = new JavaMethodCall(this, "FeedShare"); + call.Callback = callback; + call.Call(args); + } + + public override void GameGroupCreate( + string name, + string description, + string privacy, + FacebookDelegate callback) + { + MethodArguments args = new MethodArguments(); + args.AddString("name", name); + args.AddString("description", description); + args.AddString("privacy", privacy); + var gameGroupCreate = new JavaMethodCall(this, "GameGroupCreate"); + gameGroupCreate.Callback = callback; + gameGroupCreate.Call(args); + } + + public override void GameGroupJoin( + string id, + FacebookDelegate callback) + { + MethodArguments args = new MethodArguments(); + args.AddString("id", id); + var groupJoinCall = new JavaMethodCall(this, "GameGroupJoin"); + groupJoinCall.Callback = callback; + groupJoinCall.Call(args); + } + + public override void GetAppLink( + FacebookDelegate callback) + { + var getAppLink = new JavaMethodCall(this, "GetAppLink"); + getAppLink.Callback = callback; + getAppLink.Call(); + } + + public override void AppEventsLogEvent( + string logEvent, + float? valueToSum, + Dictionary parameters) + { + MethodArguments args = new MethodArguments(); + args.AddString("logEvent", logEvent); + args.AddNullablePrimitive("valueToSum", valueToSum); + args.AddDictionary("parameters", parameters); + var appEventcall = new JavaMethodCall(this, "AppEvents"); + appEventcall.Call(args); + } + + public override void AppEventsLogPurchase( + float logPurchase, + string currency, + Dictionary parameters) + { + MethodArguments args = new MethodArguments(); + args.AddPrimative("logPurchase", logPurchase); + args.AddString("currency", currency); + args.AddDictionary("parameters", parameters); + var logPurchaseCall = new JavaMethodCall(this, "AppEvents"); + logPurchaseCall.Call(args); + } + + public override void ActivateApp(string appId) + { + MethodArguments args = new MethodArguments(); + args.AddString("app_id", appId); + var activateApp = new JavaMethodCall(this, "ActivateApp"); + activateApp.Call(args); + } + + public override void FetchDeferredAppLink( + FacebookDelegate callback) + { + MethodArguments args = new MethodArguments(); + var fetchDeferredAppLinkData = new JavaMethodCall(this, "FetchDeferredAppLinkData"); + fetchDeferredAppLinkData.Callback = callback; + fetchDeferredAppLinkData.Call(args); + } + + protected override void SetShareDialogMode(ShareDialogMode mode) + { + this.CallFB("SetShareDialogMode", mode.ToString()); + } + + private void CallFB(string method, string args) + { + this.facebookJava.CallStatic(method, args); + } + + private class JavaMethodCall : MethodCall where T : IResult + { + private AndroidFacebook androidImpl; + + public JavaMethodCall(AndroidFacebook androidImpl, string methodName) + : base(androidImpl, methodName) + { + this.androidImpl = androidImpl; + } + + public override void Call(MethodArguments args = null) + { + MethodArguments paramsCopy; + if (args == null) + { + paramsCopy = new MethodArguments(); + } + else + { + paramsCopy = new MethodArguments(args); + } + + if (this.Callback != null) + { + paramsCopy.AddString("callback_id", this.androidImpl.CallbackManager.AddFacebookDelegate(this.Callback)); + } + + this.androidImpl.CallFB(this.MethodName, paramsCopy.ToJsonString()); + } + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebook.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebook.cs.meta new file mode 100644 index 000000000..91576318f --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebook.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 440199220666b43b1992ad7f24cb6b6d +timeCreated: 1438298352 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebookGameObject.cs b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebookGameObject.cs new file mode 100644 index 000000000..d5947f0c1 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebookGameObject.cs @@ -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. + */ + +namespace Facebook.Unity.Mobile.Android +{ + using System; + using UnityEngine; + + internal class AndroidFacebookGameObject : MobileFacebookGameObject + { + protected override void OnAwake() + { +#if UNITY_ANDROID + AndroidJNIHelper.debug = true; +#endif + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebookGameObject.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebookGameObject.cs.meta new file mode 100644 index 000000000..40e43dbc5 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebookGameObject.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d279c5dcf613d417dad4053abd1a3efa +timeCreated: 1438298352 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebookLoader.cs b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebookLoader.cs new file mode 100644 index 000000000..3f5f5f73e --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebookLoader.cs @@ -0,0 +1,42 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Mobile.Android +{ + using System.Collections; + using UnityEngine; + + internal class AndroidFacebookLoader : FB.CompiledFacebookLoader + { + protected override FacebookGameObject FBGameObject + { + get + { + AndroidFacebookGameObject androidFB = ComponentFactory.GetComponent(); + if (androidFB.Facebook == null) + { + androidFB.Facebook = new AndroidFacebook(); + } + + return androidFB; + } + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebookLoader.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebookLoader.cs.meta new file mode 100644 index 000000000..00ad195c5 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/AndroidFacebookLoader.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3dd549f07aac3459487895c62e7e065a +timeCreated: 1438298352 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/FBJavaClass.cs b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/FBJavaClass.cs new file mode 100644 index 000000000..ec4ac806f --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/FBJavaClass.cs @@ -0,0 +1,65 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Mobile.Android +{ + using System; + using UnityEngine; + + internal class FBJavaClass : IAndroidJavaClass + { + private const string FacebookJavaClassName = "com.facebook.unity.FB"; + private AndroidJavaClass facebookJavaClass = new AndroidJavaClass(FacebookJavaClassName); + + public T CallStatic(string methodName) + { + return this.facebookJavaClass.CallStatic(methodName); + } + + public void CallStatic(string methodName, params object[] args) + { + this.facebookJavaClass.CallStatic(methodName, args); + } + + // Mock the AndroidJava to compile on other platforms + #if !UNITY_ANDROID + private class AndroidJNIHelper + { + public static bool Debug { get; set; } + } + + private class AndroidJavaClass + { + public AndroidJavaClass(string mock) + { + } + + public T CallStatic(string method) + { + return default(T); + } + + public void CallStatic(string method, params object[] args) + { + } + } + #endif + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/FBJavaClass.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/FBJavaClass.cs.meta new file mode 100644 index 000000000..775f99daf --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/FBJavaClass.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 81a8fa1937e2543a497f6ae457206c13 +timeCreated: 1438298352 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/IAndroidJavaClass.cs b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/IAndroidJavaClass.cs new file mode 100644 index 000000000..f61e72193 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/IAndroidJavaClass.cs @@ -0,0 +1,29 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Mobile.Android +{ + internal interface IAndroidJavaClass + { + T CallStatic(string methodName); + + void CallStatic(string methodName, params object[] args); + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/IAndroidJavaClass.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/IAndroidJavaClass.cs.meta new file mode 100644 index 000000000..2b5575a21 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/Android/IAndroidJavaClass.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a94eef6b4816041188808af91a20ff6a +timeCreated: 1438298352 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebook.cs b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebook.cs new file mode 100644 index 000000000..486fecb73 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebook.cs @@ -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. + */ + +namespace Facebook.Unity.Mobile +{ + using System; + + internal interface IMobileFacebook : IFacebook + { + ShareDialogMode ShareDialogMode { get; set; } + + void AppInvite( + Uri appLinkUrl, + Uri previewImageUrl, + FacebookDelegate callback); + + void FetchDeferredAppLink( + FacebookDelegate callback); + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebook.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebook.cs.meta new file mode 100644 index 000000000..64ee08623 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebook.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7b329ba5dcada4207884a91d69ee959c +timeCreated: 1438298352 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebookCallbackHandler.cs b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebookCallbackHandler.cs new file mode 100644 index 000000000..c63915a0d --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebookCallbackHandler.cs @@ -0,0 +1,29 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Mobile +{ + internal interface IMobileFacebookCallbackHandler : IFacebookCallbackHandler + { + void OnAppInviteComplete(string message); + + void OnFetchDeferredAppLinkComplete(string message); + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebookCallbackHandler.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebookCallbackHandler.cs.meta new file mode 100644 index 000000000..7ee3fdf89 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebookCallbackHandler.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9abf702264c184f09b063485af18af80 +timeCreated: 1438298352 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebookImplementation.cs b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebookImplementation.cs new file mode 100644 index 000000000..ab75c4bc9 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebookImplementation.cs @@ -0,0 +1,26 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Mobile +{ + internal interface IMobileFacebookImplementation : IMobileFacebook, IMobileFacebookCallbackHandler + { + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebookImplementation.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebookImplementation.cs.meta new file mode 100644 index 000000000..fcff7bd03 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IMobileFacebookImplementation.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4618c388e268d4f02915ccfdad3c6e4f +timeCreated: 1438298352 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS.meta b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS.meta new file mode 100644 index 000000000..46da62d27 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: b41d78303023846989f981592eb3f704 +folderAsset: yes +timeCreated: 1438298352 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebook.cs b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebook.cs new file mode 100644 index 000000000..a698693cf --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebook.cs @@ -0,0 +1,601 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Mobile.IOS +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Runtime.InteropServices; + + internal class IOSFacebook : MobileFacebook + { + private const string CancelledResponse = "{\"cancelled\":true}"; + private bool limitEventUsage; + + public IOSFacebook() + : this(new CallbackManager()) + { + } + + public IOSFacebook(CallbackManager callbackManager) + : base(callbackManager) + { + } + + public enum FBInsightsFlushBehavior + { + FBInsightsFlushBehaviorAuto, + FBInsightsFlushBehaviorExplicitOnly, + } + + public override bool LimitEventUsage + { + get + { + return this.limitEventUsage; + } + + set + { + this.limitEventUsage = value; + IOSFacebook.IOSFBAppEventsSetLimitEventUsage(value); + } + } + + public override string FacebookSdkVersion + { + get + { + return string.Format("Facebook.iOS.SDK.{0}", IOSFacebook.IOSFBSdkVersion()); + } + } + + public override void Init( + string appId, + bool cookie, + bool logging, + bool status, + bool xfbml, + string channelUrl, + string authResponse, + bool frictionlessRequests, + HideUnityDelegate hideUnityDelegate, + InitDelegate onInitComplete) + { + base.Init( + appId, + cookie, + logging, + status, + xfbml, + channelUrl, + authResponse, + frictionlessRequests, + hideUnityDelegate, + onInitComplete); + + string unityUserAgentSuffix = string.Format( + "Unity.{0}", + Facebook.Unity.FacebookSdkVersion.Build); + + IOSFacebook.IOSInit( + appId, + cookie, + logging, + status, + frictionlessRequests, + FacebookSettings.IosURLSuffix, + unityUserAgentSuffix); + } + + public override void LogInWithReadPermissions( + IEnumerable permissions, + FacebookDelegate callback) + { + IOSFacebook.IOSLogInWithReadPermissions(this.AddCallback(callback), permissions.ToCommaSeparateList()); + } + + public override void LogInWithPublishPermissions( + IEnumerable permissions, + FacebookDelegate callback) + { + IOSFacebook.IOSLogInWithPublishPermissions(this.AddCallback(callback), permissions.ToCommaSeparateList()); + } + + public override void LogOut() + { + base.LogOut(); + IOSFacebook.IOSLogOut(); + } + + public override void AppRequest( + string message, + OGActionType? actionType, + string objectId, + IEnumerable to, + IEnumerable filters, + IEnumerable excludeIds, + int? maxRecipients, + string data, + string title, + FacebookDelegate callback) + { + this.ValidateAppRequestArgs( + message, + actionType, + objectId, + to, + filters, + excludeIds, + maxRecipients, + data, + title, + callback); + + string mobileFilter = null; + if (filters != null && filters.Any()) + { + mobileFilter = filters.First() as string; + } + + IOSFacebook.IOSAppRequest( + this.AddCallback(callback), + message, + (actionType != null) ? actionType.ToString() : string.Empty, + objectId != null ? objectId : string.Empty, + to != null ? to.ToArray() : null, + to != null ? to.Count() : 0, + mobileFilter != null ? mobileFilter : string.Empty, + excludeIds != null ? excludeIds.ToArray() : null, + excludeIds != null ? excludeIds.Count() : 0, + maxRecipients.HasValue, + maxRecipients.HasValue ? maxRecipients.Value : 0, + data, + title); + } + + public override void AppInvite( + Uri appLinkUrl, + Uri previewImageUrl, + FacebookDelegate callback) + { + string appLinkUrlStr = string.Empty; + string previewImageUrlStr = string.Empty; + if (appLinkUrl != null && !string.IsNullOrEmpty(appLinkUrl.AbsoluteUri)) + { + appLinkUrlStr = appLinkUrl.AbsoluteUri; + } + + if (previewImageUrl != null && !string.IsNullOrEmpty(previewImageUrl.AbsoluteUri)) + { + previewImageUrlStr = previewImageUrl.AbsoluteUri; + } + + IOSFacebook.IOSAppInvite( + this.AddCallback(callback), + appLinkUrlStr, + previewImageUrlStr); + } + + public override void ShareLink( + Uri contentURL, + string contentTitle, + string contentDescription, + Uri photoURL, + FacebookDelegate callback) + { + IOSFacebook.IOSShareLink( + this.AddCallback(callback), + contentURL.AbsoluteUrlOrEmptyString(), + contentTitle, + contentDescription, + photoURL.AbsoluteUrlOrEmptyString()); + } + + public override void FeedShare( + string toId, + Uri link, + string linkName, + string linkCaption, + string linkDescription, + Uri picture, + string mediaSource, + FacebookDelegate callback) + { + string linkStr = link != null ? link.ToString() : string.Empty; + string pictureStr = picture != null ? picture.ToString() : string.Empty; + IOSFacebook.IOSFeedShare( + this.AddCallback(callback), + toId, + linkStr, + linkName, + linkCaption, + linkDescription, + pictureStr, + mediaSource); + } + + public override void GameGroupCreate( + string name, + string description, + string privacy, + FacebookDelegate callback) + { + IOSFacebook.IOSCreateGameGroup(this.AddCallback(callback), name, description, privacy); + } + + public override void GameGroupJoin( + string id, + FacebookDelegate callback) + { + IOSFacebook.IOSJoinGameGroup(System.Convert.ToInt32(CallbackManager.AddFacebookDelegate(callback)), id); + } + + public override void AppEventsLogEvent( + string logEvent, + float? valueToSum, + Dictionary parameters) + { + NativeDict dict = MarshallDict(parameters); + if (valueToSum.HasValue) + { + IOSFacebook.IOSFBAppEventsLogEvent(logEvent, valueToSum.Value, dict.NumEntries, dict.Keys, dict.Values); + } + else + { + IOSFacebook.IOSFBAppEventsLogEvent(logEvent, 0.0, dict.NumEntries, dict.Keys, dict.Values); + } + } + + public override void AppEventsLogPurchase( + float logPurchase, + string currency, + Dictionary parameters) + { + NativeDict dict = MarshallDict(parameters); + IOSFacebook.IOSFBAppEventsLogPurchase(logPurchase, currency, dict.NumEntries, dict.Keys, dict.Values); + } + + public override void ActivateApp(string appId) + { + IOSFacebook.IOSFBSettingsActivateApp(appId); + } + + public override void FetchDeferredAppLink(FacebookDelegate callback) + { + IOSFacebook.IOSFetchDeferredAppLink(this.AddCallback(callback)); + } + + public override void GetAppLink( + FacebookDelegate callback) + { + IOSFacebook.IOSGetAppLink(System.Convert.ToInt32(CallbackManager.AddFacebookDelegate(callback))); + } + + protected override void SetShareDialogMode(ShareDialogMode mode) + { + IOSFacebook.IOSSetShareDialogMode((int)mode); + } + + #if UNITY_IOS + [DllImport ("__Internal")] + private static extern void IOSInit( + string appId, + bool cookie, + bool logging, + bool status, + bool frictionlessRequests, + string urlSuffix, + string unityUserAgentSuffix); + + [DllImport ("__Internal")] + private static extern void IOSLogInWithReadPermissions( + int requestId, + string scope); + + [DllImport ("__Internal")] + private static extern void IOSLogInWithPublishPermissions( + int requestId, + string scope); + + [DllImport ("__Internal")] + private static extern void IOSLogOut(); + + [DllImport ("__Internal")] + private static extern void IOSSetShareDialogMode(int mode); + + [DllImport ("__Internal")] + private static extern void IOSShareLink( + int requestId, + string contentURL, + string contentTitle, + string contentDescription, + string photoURL); + + [DllImport ("__Internal")] + public static extern void IOSFeedShare( + int requestId, + string toId, + string link, + string linkName, + string linkCaption, + string linkDescription, + string picture, + string mediaSource); + + [DllImport ("__Internal")] + private static extern void IOSAppRequest( + int requestId, + string message, + string actionType, + string objectId, + string[] to = null, + int toLength = 0, + string filters = "", + string[] excludeIds = null, + int excludeIdsLength = 0, + bool hasMaxRecipients = false, + int maxRecipients = 0, + string data = "", + string title = ""); + + [DllImport ("__Internal")] + private static extern void IOSAppInvite( + int requestId, + string appLinkUrl, + string previewImageUrl); + + [DllImport ("__Internal")] + private static extern void IOSCreateGameGroup( + int requestId, + string name, + string description, + string privacy); + + [DllImport ("__Internal")] + private static extern void IOSJoinGameGroup(int requestId, string groupId); + + [DllImport ("__Internal")] + private static extern void IOSFBSettingsActivateApp(string appId); + + [DllImport ("__Internal")] + private static extern void IOSFBAppEventsLogEvent( + string logEvent, + double valueToSum, + int numParams, + string[] paramKeys, + string[] paramVals); + + [DllImport ("__Internal")] + private static extern void IOSFBAppEventsLogPurchase( + double logPurchase, + string currency, + int numParams, + string[] paramKeys, + string[] paramVals); + + [DllImport ("__Internal")] + private static extern void IOSFBAppEventsSetLimitEventUsage(bool limitEventUsage); + + [DllImport ("__Internal")] + private static extern void IOSGetAppLink(int requestID); + + [DllImport ("__Internal")] + private static extern string IOSFBSdkVersion(); + + [DllImport ("__Internal")] + private static extern void IOSFetchDeferredAppLink(int requestID); + #else + private static void IOSInit( + string appId, + bool cookie, + bool logging, + bool status, + bool frictionlessRequests, + string urlSuffix, + string unityUserAgentSuffix) + { + } + + private static void IOSLogInWithReadPermissions( + int requestId, + string scope) + { + } + + private static void IOSLogInWithPublishPermissions( + int requestId, + string scope) + { + } + + private static void IOSLogOut() + { + } + + private static void IOSSetShareDialogMode(int mode) + { + } + + private static void IOSShareLink( + int requestId, + string contentURL, + string contentTitle, + string contentDescription, + string photoURL) + { + } + + private static void IOSFeedShare( + int requestId, + string toId, + string link, + string linkName, + string linkCaption, + string linkDescription, + string picture, + string mediaSource) + { + } + + private static void IOSAppRequest( + int requestId, + string message, + string actionType, + string objectId, + string[] to = null, + int toLength = 0, + string filters = "", + string[] excludeIds = null, + int excludeIdsLength = 0, + bool hasMaxRecipients = false, + int maxRecipients = 0, + string data = "", + string title = "") + { + } + + private static void IOSAppInvite( + int requestId, + string appLinkUrl, + string previewImageUrl) + { + } + + private static void IOSCreateGameGroup( + int requestId, + string name, + string description, + string privacy) + { + } + + private static void IOSJoinGameGroup(int requestId, string groupId) + { + } + + private static void IOSFBSettingsPublishInstall(int requestId, string appId) + { + } + + private static void IOSFBSettingsActivateApp(string appId) + { + } + + private static void IOSFBAppEventsLogEvent( + string logEvent, + double valueToSum, + int numParams, + string[] paramKeys, + string[] paramVals) + { + } + + private static void IOSFBAppEventsLogPurchase( + double logPurchase, + string currency, + int numParams, + string[] paramKeys, + string[] paramVals) + { + } + + private static void IOSFBAppEventsSetLimitEventUsage(bool limitEventUsage) + { + } + + private static void IOSGetAppLink(int requestId) + { + } + + private static string IOSFBSdkVersion() + { + return "NONE"; + } + + private static void IOSFetchDeferredAppLink(int requestId) + { + } + #endif + + private static NativeDict MarshallDict(Dictionary dict) + { + NativeDict res = new NativeDict(); + + if (dict != null && dict.Count > 0) + { + res.Keys = new string[dict.Count]; + res.Values = new string[dict.Count]; + res.NumEntries = 0; + foreach (KeyValuePair kvp in dict) + { + res.Keys[res.NumEntries] = kvp.Key; + res.Values[res.NumEntries] = kvp.Value.ToString(); + res.NumEntries++; + } + } + + return res; + } + + private static NativeDict MarshallDict(Dictionary dict) + { + NativeDict res = new NativeDict(); + + if (dict != null && dict.Count > 0) + { + res.Keys = new string[dict.Count]; + res.Values = new string[dict.Count]; + res.NumEntries = 0; + foreach (KeyValuePair kvp in dict) + { + res.Keys[res.NumEntries] = kvp.Key; + res.Values[res.NumEntries] = kvp.Value; + res.NumEntries++; + } + } + + return res; + } + + private int AddCallback(FacebookDelegate callback) where T : IResult + { + string asyncId = this.CallbackManager.AddFacebookDelegate(callback); + return Convert.ToInt32(asyncId); + } + + private class NativeDict + { + public NativeDict() + { + this.NumEntries = 0; + this.Keys = null; + this.Values = null; + } + + public int NumEntries { get; set; } + + public string[] Keys { get; set; } + + public string[] Values { get; set; } + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebook.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebook.cs.meta new file mode 100644 index 000000000..07d08bdf8 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebook.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: aae9d13c8ad194c66b332d1a5c4821f7 +timeCreated: 1438298352 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebookGameObject.cs b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebookGameObject.cs new file mode 100644 index 000000000..d30e16ae6 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebookGameObject.cs @@ -0,0 +1,26 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Mobile.IOS +{ + internal class IOSFacebookGameObject : MobileFacebookGameObject + { + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebookGameObject.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebookGameObject.cs.meta new file mode 100644 index 000000000..4cde0c6d6 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebookGameObject.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: acca4ef0877ea4dee9be08fa512193b5 +timeCreated: 1438298352 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebookLoader.cs b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebookLoader.cs new file mode 100644 index 000000000..32feabf71 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebookLoader.cs @@ -0,0 +1,42 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Mobile.IOS +{ + using System.Collections; + using UnityEngine; + + internal class IOSFacebookLoader : FB.CompiledFacebookLoader + { + protected override FacebookGameObject FBGameObject + { + get + { + IOSFacebookGameObject iosFB = ComponentFactory.GetComponent(); + if (iosFB.Facebook == null) + { + iosFB.Facebook = new IOSFacebook(); + } + + return iosFB; + } + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebookLoader.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebookLoader.cs.meta new file mode 100644 index 000000000..8071b78ba --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/IOS/IOSFacebookLoader.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fbfae18b917df404cac98fc89fe70cf1 +timeCreated: 1438298355 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/MobileFacebook.cs b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/MobileFacebook.cs new file mode 100644 index 000000000..dd1d323e8 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/MobileFacebook.cs @@ -0,0 +1,151 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Mobile +{ + using System; + using System.Collections.Generic; + using System.Linq; + + /// + /// Classes defined on the mobile sdks + /// + internal abstract class MobileFacebook : FacebookBase, IMobileFacebookImplementation + { + private const string CallbackIdKey = "callback_id"; + private ShareDialogMode shareDialogMode = ShareDialogMode.AUTOMATIC; + + protected MobileFacebook(CallbackManager callbackManager) : base(callbackManager) + { + } + + /// + /// Gets or sets the dialog mode. + /// + /// The dialog mode use for sharing, login, and other dialogs. + public ShareDialogMode ShareDialogMode + { + get + { + return this.shareDialogMode; + } + + set + { + this.shareDialogMode = value; + this.SetShareDialogMode(this.shareDialogMode); + } + } + + public abstract void AppInvite( + Uri appLinkUrl, + Uri previewImageUrl, + FacebookDelegate callback); + + public abstract void FetchDeferredAppLink( + FacebookDelegate callback); + + public override void OnLoginComplete(string message) + { + var result = new LoginResult(message); + this.OnAuthResponse(result); + } + + public override void OnGetAppLinkComplete(string message) + { + var result = new AppLinkResult(message); + CallbackManager.OnFacebookResponse(result); + } + + public override void OnGroupCreateComplete(string message) + { + var result = new GroupCreateResult(message); + CallbackManager.OnFacebookResponse(result); + } + + public override void OnGroupJoinComplete(string message) + { + var result = new GroupJoinResult(message); + CallbackManager.OnFacebookResponse(result); + } + + public override void OnAppRequestsComplete(string message) + { + var result = new AppRequestResult(message); + CallbackManager.OnFacebookResponse(result); + } + + public void OnAppInviteComplete(string message) + { + var result = new AppInviteResult(message); + CallbackManager.OnFacebookResponse(result); + } + + public void OnFetchDeferredAppLinkComplete(string message) + { + var result = new AppLinkResult(message); + CallbackManager.OnFacebookResponse(result); + } + + public override void OnShareLinkComplete(string message) + { + var result = new ShareResult(message); + CallbackManager.OnFacebookResponse(result); + } + + protected abstract void SetShareDialogMode(ShareDialogMode mode); + + private static IDictionary DeserializeMessage(string message) + { + return (Dictionary)MiniJSON.Json.Deserialize(message); + } + + private static string SerializeDictionary(IDictionary dict) + { + return MiniJSON.Json.Serialize(dict); + } + + private static bool TryGetCallbackId(IDictionary result, out string callbackId) + { + object callback; + callbackId = null; + if (result.TryGetValue("callback_id", out callback)) + { + callbackId = callback as string; + return true; + } + + return false; + } + + private static bool TryGetError(IDictionary result, out string errorMessage) + { + object error; + errorMessage = null; + if (result.TryGetValue("error", out error)) + { + errorMessage = error as string; + return true; + } + + return false; + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/MobileFacebook.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/MobileFacebook.cs.meta new file mode 100644 index 000000000..22d5dbff1 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/MobileFacebook.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8ab9887ef875b4202bf9d0f3471ecbad +timeCreated: 1438298352 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/MobileFacebookGameObject.cs b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/MobileFacebookGameObject.cs new file mode 100644 index 000000000..a23a2c780 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/MobileFacebookGameObject.cs @@ -0,0 +1,45 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Mobile +{ + using System; + + internal abstract class MobileFacebookGameObject : FacebookGameObject, IMobileFacebookCallbackHandler + { + private IMobileFacebookImplementation MobileFacebook + { + get + { + return (IMobileFacebookImplementation)this.Facebook; + } + } + + public void OnAppInviteComplete(string message) + { + this.MobileFacebook.OnAppInviteComplete(message); + } + + public void OnFetchDeferredAppLinkComplete(string message) + { + this.MobileFacebook.OnFetchDeferredAppLinkComplete(message); + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Mobile/MobileFacebookGameObject.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/MobileFacebookGameObject.cs.meta new file mode 100644 index 000000000..bcaea5f1d --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Mobile/MobileFacebookGameObject.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f95c2bd557fca4be3a850d77547ecb1c +timeCreated: 1439320084 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/NativeDialogModes.cs b/Facebook.Unity/Assets/Facebook/Scripts/NativeDialogModes.cs new file mode 100644 index 000000000..958c8d964 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/NativeDialogModes.cs @@ -0,0 +1,48 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + // If you make changes in here make the same changes in Assets/Facebook/Editor/iOS/FBUnityInterface.h + public enum ShareDialogMode + { + /// + /// The sdk will choose which type of dialog to show + /// See the Facebook SDKs for ios and android for specific details. + /// + AUTOMATIC = 0, + + /// + /// Uses the dialog inside the native facebook applications. Note this will fail if the + /// native applications are not installed. + /// + NATIVE = 1, + + /// + /// Opens the facebook dialog in a webview. + /// + WEB = 2, + + /// + /// Uses the feed dialog. + /// + FEED = 3, + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/NativeDialogModes.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/NativeDialogModes.cs.meta new file mode 100644 index 000000000..4e81c2edd --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/NativeDialogModes.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2e09a2235c14f43188e85db884c4d07d +timeCreated: 1435009385 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/OGActionType.cs b/Facebook.Unity/Assets/Facebook/Scripts/OGActionType.cs new file mode 100644 index 000000000..bbbc88956 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/OGActionType.cs @@ -0,0 +1,29 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + public enum OGActionType + { + SEND, + ASKFOR, + TURN, + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/OGActionType.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/OGActionType.cs.meta new file mode 100644 index 000000000..163cd677f --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/OGActionType.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8723df1a5538be14f8a8452a43b1f07e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/PlatformAndroid.meta b/Facebook.Unity/Assets/Facebook/Scripts/PlatformAndroid.meta new file mode 100644 index 000000000..10cc21841 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/PlatformAndroid.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 36803103b58964b2eb95d48d79ebf961 +folderAsset: yes +timeCreated: 1432149441 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor.meta b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor.meta new file mode 100644 index 000000000..fb06eeb40 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 6c73d96350c594fabb057b686fe7542e +folderAsset: yes +timeCreated: 1432149472 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebook.cs b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebook.cs new file mode 100644 index 000000000..c059bc3b4 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebook.cs @@ -0,0 +1,313 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Editor +{ + using System; + using System.Collections; + using System.Collections.Generic; + using Facebook.Unity.Canvas; + using Facebook.Unity.Editor.Dialogs; + using Facebook.Unity.Mobile; + using UnityEngine; + + internal class EditorFacebook : FacebookBase, IMobileFacebookImplementation, ICanvasFacebookImplementation + { + private const string WarningMessage = "You are using the facebook SDK in the Unity Editor. " + + "Behavior may not be the same as when used on iOS, Android, or Web."; + + private const string AccessTokenKey = "com.facebook.unity.editor.accesstoken"; + + public EditorFacebook() : base(new CallbackManager()) + { + } + + public override bool LimitEventUsage { get; set; } + + public ShareDialogMode ShareDialogMode { get; set; } + + public override string FacebookSdkVersion + { + get + { + return "None"; + } + } + + private IFacebookCallbackHandler EditorGameObject + { + get + { + return ComponentFactory.GetComponent(); + } + } + + public override void Init( + string appId, + bool cookie, + bool logging, + bool status, + bool xfbml, + string channelUrl, + string authResponse, + bool frictionlessRequests, + HideUnityDelegate hideUnityDelegate, + InitDelegate onInitComplete) + { + // Warn that editor behavior will not match supported platforms + FacebookLogger.Warn(WarningMessage); + + base.Init( + appId, + cookie, + logging, + status, + xfbml, + channelUrl, + authResponse, + frictionlessRequests, + hideUnityDelegate, + onInitComplete); + + this.EditorGameObject.OnInitComplete(string.Empty); + } + + public override void LogInWithReadPermissions( + IEnumerable permissions, + FacebookDelegate callback) + { + // For the editor don't worry about the difference between + // LogInWithReadPermissions and LogInWithPublishPermissions + this.LogInWithPublishPermissions(permissions, callback); + } + + public override void LogInWithPublishPermissions( + IEnumerable permissions, + FacebookDelegate callback) + { + var dialog = ComponentFactory.GetComponent(); + dialog.Callback = this.EditorGameObject.OnLoginComplete; + dialog.CallbackID = this.CallbackManager.AddFacebookDelegate(callback); + dialog.Permissions = permissions != null ? permissions : new List(); + } + + public override void AppRequest( + string message, + OGActionType? actionType, + string objectId, + IEnumerable to, + IEnumerable filters, + IEnumerable excludeIds, + int? maxRecipients, + string data, + string title, + FacebookDelegate callback) + { + this.ShowEmptyMockDialog(this.OnAppRequestsComplete, callback, "Mock App Request"); + } + + public override void ShareLink( + Uri contentURL, + string contentTitle, + string contentDescription, + Uri photoURL, + FacebookDelegate callback) + { + this.ShowEmptyMockDialog(this.OnShareLinkComplete, callback, "Mock Share Link"); + } + + public override void FeedShare( + string toId, + Uri link, + string linkName, + string linkCaption, + string linkDescription, + Uri picture, + string mediaSource, + FacebookDelegate callback) + { + this.ShowEmptyMockDialog(this.OnShareLinkComplete, callback, "Mock Feed Share"); + } + + public override void GameGroupCreate( + string name, + string description, + string privacy, + FacebookDelegate callback) + { + this.ShowEmptyMockDialog(this.OnGroupCreateComplete, callback, "Mock Group Create"); + } + + public override void GameGroupJoin( + string id, + FacebookDelegate callback) + { + this.ShowEmptyMockDialog(this.OnGroupJoinComplete, callback, "Mock Group Join"); + } + + public override void ActivateApp(string appId) + { + FacebookLogger.Info("This only needs to be called for iOS or Android."); + } + + public override void GetAppLink(FacebookDelegate callback) + { + var result = new Dictionary(); + result[Constants.UrlKey] = "mockurl://testing.url"; + result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback); + this.OnGetAppLinkComplete(MiniJSON.Json.Serialize(result)); + } + + public override void AppEventsLogEvent( + string logEvent, + float? valueToSum, + Dictionary parameters) + { + FacebookLogger.Log("Pew! Pretending to send this off. Doesn't actually work in the editor"); + } + + public override void AppEventsLogPurchase( + float logPurchase, + string currency, + Dictionary parameters) + { + FacebookLogger.Log("Pew! Pretending to send this off. Doesn't actually work in the editor"); + } + + public void AppInvite( + Uri appLinkUrl, + Uri previewImageUrl, + FacebookDelegate callback) + { + this.ShowEmptyMockDialog(this.OnAppInviteComplete, callback, "Mock App Invite"); + } + + public void FetchDeferredAppLink( + FacebookDelegate callback) + { + var result = new Dictionary(); + result[Constants.UrlKey] = "mockurl://testing.url"; + result[Constants.RefKey] = "mock ref"; + result[Constants.ExtrasKey] = new Dictionary() + { + { + "mock extra key", "mock extra value" + } + }; + + result[Constants.TargetUrlKey] = "mocktargeturl://mocktarget.url"; + result[Constants.CallbackIdKey] = this.CallbackManager.AddFacebookDelegate(callback); + this.OnFetchDeferredAppLinkComplete(MiniJSON.Json.Serialize(result)); + } + + public void Pay( + string product, + string action, + int quantity, + int? quantityMin, + int? quantityMax, + string requestId, + string pricepointId, + string testCurrency, + FacebookDelegate callback) + { + this.ShowEmptyMockDialog(this.OnPayComplete, callback, "Mock Pay Dialog"); + } + + public override void OnAppRequestsComplete(string message) + { + var result = new AppRequestResult(message); + CallbackManager.OnFacebookResponse(result); + } + + public override void OnGetAppLinkComplete(string message) + { + var result = new AppLinkResult(message); + CallbackManager.OnFacebookResponse(result); + } + + public override void OnGroupCreateComplete(string message) + { + var result = new GroupCreateResult(message); + CallbackManager.OnFacebookResponse(result); + } + + public override void OnGroupJoinComplete(string message) + { + var result = new GroupJoinResult(message); + CallbackManager.OnFacebookResponse(result); + } + + public override void OnLoginComplete(string message) + { + var result = new LoginResult(message); + this.OnAuthResponse(result); + } + + public override void OnShareLinkComplete(string message) + { + var result = new ShareResult(message); + CallbackManager.OnFacebookResponse(result); + } + + public void OnAppInviteComplete(string message) + { + var result = new AppInviteResult(message); + CallbackManager.OnFacebookResponse(result); + } + + public void OnFetchDeferredAppLinkComplete(string message) + { + var result = new AppLinkResult(message); + CallbackManager.OnFacebookResponse(result); + } + + public void OnPayComplete(string message) + { + var result = new PayResult(message); + CallbackManager.OnFacebookResponse(result); + } + + #region Canvas Dummy Methods + + public void OnFacebookAuthResponseChange(string message) + { + throw new NotSupportedException(); + } + + public void OnUrlResponse(string message) + { + throw new NotSupportedException(); + } + + #endregion + + private void ShowEmptyMockDialog( + EditorFacebookMockDialog.OnComplete callback, + FacebookDelegate userCallback, + string title) where T : IResult + { + var dialog = ComponentFactory.GetComponent(); + dialog.Callback = callback; + dialog.CallbackID = this.CallbackManager.AddFacebookDelegate(userCallback); + dialog.EmptyDialogTitle = title; + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebook.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebook.cs.meta new file mode 100644 index 000000000..7987e7aea --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebook.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9ed7a0cb5697e2b4ab1584baaf491801 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookGameObject.cs b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookGameObject.cs new file mode 100644 index 000000000..2a946754d --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookGameObject.cs @@ -0,0 +1,26 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Editor +{ + internal class EditorFacebookGameObject : FacebookGameObject + { + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookGameObject.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookGameObject.cs.meta new file mode 100644 index 000000000..cd80311c7 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookGameObject.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a6902ec28de324a05807bb5a76fd51f1 +timeCreated: 1438126101 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookLoader.cs b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookLoader.cs new file mode 100644 index 000000000..e1cff4350 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookLoader.cs @@ -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. + */ + +namespace Facebook.Unity.Editor +{ + using System.Collections; + + internal class EditorFacebookLoader : FB.CompiledFacebookLoader + { + protected override FacebookGameObject FBGameObject + { + get + { + EditorFacebookGameObject editorFB = ComponentFactory.GetComponent(); + editorFB.Facebook = new EditorFacebook(); + return editorFB; + } + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookLoader.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookLoader.cs.meta new file mode 100644 index 000000000..052df9990 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookLoader.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 839c49b18c5f56c4080f08d0e6b6ca15 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookMockDialog.cs b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookMockDialog.cs new file mode 100644 index 000000000..d06a23271 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookMockDialog.cs @@ -0,0 +1,125 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Editor +{ + using System; + using System.Collections.Generic; + using UnityEngine; + + internal abstract class EditorFacebookMockDialog : MonoBehaviour + { + private float windowHeight = 200; + private GUIStyle greyButton; + + public delegate void OnComplete(string result); + + public OnComplete Callback { protected get; set; } + + public string CallbackID { protected get; set; } + + protected abstract float WindowHeight { get; } + + protected abstract string DialogTitle { get; } + + public void OnGUI() + { + var windowTop = (Screen.height / 2) - (this.WindowHeight / 2); + var windowLeft = (Screen.width / 2) - (this.WindowHeight / 2); + this.greyButton = GUI.skin.button; + GUI.ModalWindow( + this.GetHashCode(), + new Rect(windowLeft, windowTop, this.WindowHeight, this.windowHeight), + this.OnGUIDialog, + this.DialogTitle); + } + + protected abstract void DoGui(); + + protected abstract void SendSuccessResult(); + + protected void SendCancelResult() + { + var dictionary = new Dictionary(); + dictionary[Constants.CancelledKey] = true; + if (!string.IsNullOrEmpty(this.CallbackID)) + { + dictionary[Constants.CallbackIdKey] = this.CallbackID; + } + + this.Callback(MiniJSON.Json.Serialize(dictionary)); + } + + protected void SendErrorResult(string errorMessage) + { + var dictionary = new Dictionary(); + dictionary[Constants.ErrorKey] = errorMessage; + if (!string.IsNullOrEmpty(this.CallbackID)) + { + dictionary[Constants.CallbackIdKey] = this.CallbackID; + } + + this.Callback(MiniJSON.Json.Serialize(dictionary)); + } + + private void OnGUIDialog(int windowId) + { + GUILayout.Space(10); + GUILayout.BeginVertical(); + GUILayout.Label("Warning! Mock dialog responses will NOT match production dialogs"); + GUILayout.Label("Test your app on one of the supported platforms"); + this.DoGui(); + GUILayout.EndVertical(); + + GUILayout.BeginHorizontal(); + GUILayout.FlexibleSpace(); + var loginLabel = new GUIContent("Send Success"); + var buttonRect = GUILayoutUtility.GetRect(loginLabel, GUI.skin.button); + if (GUI.Button(buttonRect, loginLabel)) + { + this.SendSuccessResult(); + MonoBehaviour.Destroy(this); + } + + var cancelLabel = new GUIContent("Send Cancel"); + var cancelButtonRect = GUILayoutUtility.GetRect(cancelLabel, this.greyButton); + if (GUI.Button(cancelButtonRect, cancelLabel, this.greyButton)) + { + this.SendCancelResult(); + MonoBehaviour.Destroy(this); + } + + var errorLabel = new GUIContent("Send Error"); + var errorButtonRect = GUILayoutUtility.GetRect(cancelLabel, this.greyButton); + if (GUI.Button(errorButtonRect, errorLabel, this.greyButton)) + { + this.SendErrorResult("Error: Error button pressed"); + MonoBehaviour.Destroy(this); + } + + GUILayout.EndHorizontal(); + + if (Event.current.type == EventType.Repaint) + { + this.windowHeight = cancelButtonRect.y + cancelButtonRect.height + GUI.skin.window.padding.bottom; + } + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookMockDialog.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookMockDialog.cs.meta new file mode 100644 index 000000000..87db7a305 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/EditorFacebookMockDialog.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4b00b7a3f53674aee868d4ea170d814d +timeCreated: 1440621472 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/MockDialogs.meta b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/MockDialogs.meta new file mode 100644 index 000000000..e4078fcc0 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/MockDialogs.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 056932e098e6f45429c4522ca0471b7c +folderAsset: yes +timeCreated: 1440621472 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/MockDialogs/EmptyMockDialog.cs b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/MockDialogs/EmptyMockDialog.cs new file mode 100644 index 000000000..ac527a724 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/MockDialogs/EmptyMockDialog.cs @@ -0,0 +1,67 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Editor.Dialogs +{ + using System; + using System.Collections.Generic; + using UnityEngine; + + internal class EmptyMockDialog : EditorFacebookMockDialog + { + public string EmptyDialogTitle { get; set; } + + protected override float WindowHeight + { + get + { + return 500; + } + } + + protected override string DialogTitle + { + get + { + return this.EmptyDialogTitle; + } + } + + protected override void DoGui() + { + // Empty + } + + protected override void SendSuccessResult() + { + var result = new Dictionary(); + result["did_complete"] = true; + if (!string.IsNullOrEmpty(this.CallbackID)) + { + result[Constants.CallbackIdKey] = this.CallbackID; + } + + if (this.Callback != null) + { + this.Callback(MiniJSON.Json.Serialize(result)); + } + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/MockDialogs/EmptyMockDialog.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/MockDialogs/EmptyMockDialog.cs.meta new file mode 100644 index 000000000..b0a67f0df --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/MockDialogs/EmptyMockDialog.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fda4fa36c1a664b1d854e713e025a1fd +timeCreated: 1440629408 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/MockDialogs/MockLoginDialog.cs b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/MockDialogs/MockLoginDialog.cs new file mode 100644 index 000000000..149b69b74 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/MockDialogs/MockLoginDialog.cs @@ -0,0 +1,88 @@ +/** + * 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. + */ + +namespace Facebook.Unity.Editor.Dialogs +{ + using System; + using System.Collections.Generic; + using System.Linq; + using UnityEngine; + + internal class MockLoginDialog : EditorFacebookMockDialog + { + private string accessToken = string.Empty; + + public IEnumerable Permissions { private get; set; } + + protected override float WindowHeight + { + get + { + return 592; + } + } + + protected override string DialogTitle + { + get + { + return "Mock Login Dialog"; + } + } + + protected override void DoGui() + { + GUILayout.BeginHorizontal(); + GUILayout.Label("User Access Token:"); + this.accessToken = GUILayout.TextField(this.accessToken, GUI.skin.textArea, GUILayout.MinWidth(400)); + GUILayout.EndHorizontal(); + GUILayout.Space(20); + if (GUILayout.Button("Find Access Token")) + { + Application.OpenURL(string.Format("https://developers.facebook.com/tools/accesstoken/?app_id={0}", FB.AppId)); + } + } + + protected override void SendSuccessResult() + { + if (string.IsNullOrEmpty(this.accessToken)) + { + this.SendErrorResult("Empty Access token string"); + return; + } + + var token = new AccessToken( + this.accessToken, + "MockUserId", + DateTime.Now.AddDays(60), + this.Permissions); + var result = (IDictionary)MiniJSON.Json.Deserialize(token.ToJson()); + if (!string.IsNullOrEmpty(this.CallbackID)) + { + result[Constants.CallbackIdKey] = this.CallbackID; + } + + if (this.Callback != null) + { + this.Callback(MiniJSON.Json.Serialize(result)); + } + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/MockDialogs/MockLoginDialog.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/MockDialogs/MockLoginDialog.cs.meta new file mode 100644 index 000000000..35b9b8a56 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/PlatformEditor/MockDialogs/MockLoginDialog.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0757441489d0b42e6bf53c4f4ad951cf +timeCreated: 1440621472 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/PlatformIOS.meta b/Facebook.Unity/Assets/Facebook/Scripts/PlatformIOS.meta new file mode 100644 index 000000000..af58887c9 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/PlatformIOS.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: fe115c6deb762415f99b02f1a8316c9d +folderAsset: yes +timeCreated: 1432149452 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Properties.meta b/Facebook.Unity/Assets/Facebook/Scripts/Properties.meta new file mode 100644 index 000000000..2fedfd210 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Properties.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 2f26a1520326c4ff0a9626f01da8f550 +folderAsset: yes +timeCreated: 1438148489 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Properties/AssemblyInfo.cs b/Facebook.Unity/Assets/Facebook/Scripts/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..79bc9fae8 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Properties/AssemblyInfo.cs @@ -0,0 +1,23 @@ +/** + * 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. + */ + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Facebook.Unity.Tests")] diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Properties/AssemblyInfo.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Properties/AssemblyInfo.cs.meta new file mode 100644 index 000000000..17f559035 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Properties/AssemblyInfo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0f63b168ef77c4d6284fa3fad2578dc3 +timeCreated: 1438148489 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results.meta b/Facebook.Unity/Assets/Facebook/Scripts/Results.meta new file mode 100644 index 000000000..6b80d95da --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: a9488f2143029498dbd9c7c7b03462b3 +folderAsset: yes +timeCreated: 1438148489 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/AppInviteResult.cs b/Facebook.Unity/Assets/Facebook/Scripts/Results/AppInviteResult.cs new file mode 100644 index 000000000..aece0c36c --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/AppInviteResult.cs @@ -0,0 +1,29 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + internal class AppInviteResult : ResultBase, IAppInviteResult + { + public AppInviteResult(string result) : base(result) + { + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/AppInviteResult.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Results/AppInviteResult.cs.meta new file mode 100644 index 000000000..2f46f4e46 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/AppInviteResult.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9c6a27f84463c4c3fb43499e34945d04 +timeCreated: 1438022175 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/AppLinkResult.cs b/Facebook.Unity/Assets/Facebook/Scripts/Results/AppLinkResult.cs new file mode 100644 index 000000000..30a40642a --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/AppLinkResult.cs @@ -0,0 +1,66 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using System; + using System.Collections.Generic; + + internal class AppLinkResult : ResultBase, IAppLinkResult + { + public AppLinkResult(string result) : base(result) + { + if (this.ResultDictionary != null) + { + string url; + if (this.ResultDictionary.TryGetValue(Constants.UrlKey, out url)) + { + this.Url = url; + } + + string targetUrl; + if (this.ResultDictionary.TryGetValue(Constants.TargetUrlKey, out targetUrl)) + { + this.TargetUrl = targetUrl; + } + + string refStr; + if (this.ResultDictionary.TryGetValue(Constants.RefKey, out refStr)) + { + this.Ref = refStr; + } + + IDictionary argumentBundle; + if (this.ResultDictionary.TryGetValue>(Constants.ExtrasKey, out argumentBundle)) + { + this.Extras = argumentBundle; + } + } + } + + public string Url { get; private set; } + + public string TargetUrl { get; private set; } + + public string Ref { get; private set; } + + public IDictionary Extras { get; private set; } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/AppLinkResult.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Results/AppLinkResult.cs.meta new file mode 100644 index 000000000..37d774286 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/AppLinkResult.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: bec89852b7bec4aa296e808dd38e4080 +timeCreated: 1440787581 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/AppReqeustResult.cs b/Facebook.Unity/Assets/Facebook/Scripts/Results/AppReqeustResult.cs new file mode 100644 index 000000000..9bd223028 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/AppReqeustResult.cs @@ -0,0 +1,51 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using System.Collections; + using System.Collections.Generic; + using UnityEngine; + + internal class AppRequestResult : ResultBase, IAppRequestResult + { + public AppRequestResult(string result) : base(result) + { + if (this.ResultDictionary != null) + { + string requestID; + if (this.ResultDictionary.TryGetValue("request", out requestID)) + { + this.RequestID = requestID; + } + + string toStr; + if (this.ResultDictionary.TryGetValue("to", out toStr)) + { + this.To = toStr.Split(','); + } + } + } + + public string RequestID { get; private set; } + + public IEnumerable To { get; private set; } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/AppReqeustResult.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Results/AppReqeustResult.cs.meta new file mode 100644 index 000000000..1b0ae974b --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/AppReqeustResult.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b58e26ce8d12a46d9be1830a6199e263 +timeCreated: 1438027471 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/GraphResult.cs b/Facebook.Unity/Assets/Facebook/Scripts/Results/GraphResult.cs new file mode 100644 index 000000000..022ce5496 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/GraphResult.cs @@ -0,0 +1,60 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using System; + using System.Collections; + using System.Collections.Generic; + using UnityEngine; + + internal class GraphResult : ResultBase, IGraphResult + { + internal GraphResult(WWW result) : base(result.text, result.error, false) + { + this.Init(this.RawResult); + } + + public IList ResultList { get; private set; } + + private void Init(string rawResult) + { + if (string.IsNullOrEmpty(rawResult)) + { + return; + } + + object serailizedResult = MiniJSON.Json.Deserialize(this.RawResult); + var jsonObject = serailizedResult as IDictionary; + if (jsonObject != null) + { + this.ResultDictionary = jsonObject; + return; + } + + var jsonArray = serailizedResult as IList; + if (jsonArray != null) + { + this.ResultList = jsonArray; + return; + } + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/GraphResult.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Results/GraphResult.cs.meta new file mode 100644 index 000000000..8c41b86a0 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/GraphResult.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: de1998eed36b34443889243c11a3702d +timeCreated: 1437503163 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/GroupCreateResult.cs b/Facebook.Unity/Assets/Facebook/Scripts/Results/GroupCreateResult.cs new file mode 100644 index 000000000..d3e0065fb --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/GroupCreateResult.cs @@ -0,0 +1,41 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using System.Collections; + + internal class GroupCreateResult : ResultBase, IGroupCreateResult + { + internal GroupCreateResult(string result) : base(result) + { + if (this.ResultDictionary != null) + { + string groupId; + if (this.ResultDictionary.TryGetValue("id", out groupId)) + { + this.GroupId = groupId; + } + } + } + + public string GroupId { get; private set; } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/GroupCreateResult.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Results/GroupCreateResult.cs.meta new file mode 100644 index 000000000..1e0d0757d --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/GroupCreateResult.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0e2a718c5d26d45478cce74d21eb261c +timeCreated: 1437594644 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/GroupJoinResult.cs b/Facebook.Unity/Assets/Facebook/Scripts/Results/GroupJoinResult.cs new file mode 100644 index 000000000..cdb19d800 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/GroupJoinResult.cs @@ -0,0 +1,29 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + internal class GroupJoinResult : ResultBase, IGroupJoinResult + { + internal GroupJoinResult(string result) : base(result) + { + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/GroupJoinResult.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Results/GroupJoinResult.cs.meta new file mode 100644 index 000000000..763b8b03f --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/GroupJoinResult.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 84a179d58bd30446187e9d5108988f5e +timeCreated: 1437596346 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/IAppInviteResult.cs b/Facebook.Unity/Assets/Facebook/Scripts/Results/IAppInviteResult.cs new file mode 100644 index 000000000..959939f58 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/IAppInviteResult.cs @@ -0,0 +1,29 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + /// + /// The result of an app invite. + /// + public interface IAppInviteResult : IResult + { + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/IAppInviteResult.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Results/IAppInviteResult.cs.meta new file mode 100644 index 000000000..5a3a3e689 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/IAppInviteResult.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: cc8ae3352b83e4c908901b1525ee31fc +timeCreated: 1438289533 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/IAppLinkResult.cs b/Facebook.Unity/Assets/Facebook/Scripts/Results/IAppLinkResult.cs new file mode 100644 index 000000000..273cf3e0a --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/IAppLinkResult.cs @@ -0,0 +1,61 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using System; + using System.Collections.Generic; + + /// + /// A result containing an app link + /// + public interface IAppLinkResult : IResult + { + /// + /// Gets the URL. + /// + /// The link url. + string Url { get; } + + /// + /// Gets the target URI. + /// + /// The target uri for this App Link.. + string TargetUrl { get; } + + /// + /// Gets the ref. + /// + /// Returns the ref for this App Link. + /// The referer data associated with the app link. + /// This will contain Facebook specific information like fb_access_token, fb_expires_in, and fb_ref. + /// + string Ref { get; } + + /// + /// Gets the extras data. + /// + /// + /// The full set of arguments for this app link. Properties like target uri & ref are typically + /// picked out of this set of arguments. + /// + IDictionary Extras { get; } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/IAppLinkResult.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Results/IAppLinkResult.cs.meta new file mode 100644 index 000000000..451d91824 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/IAppLinkResult.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 85e0c9fb868934e47aedbccbfec45de9 +timeCreated: 1440787581 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/IAppRequestResult.cs b/Facebook.Unity/Assets/Facebook/Scripts/Results/IAppRequestResult.cs new file mode 100644 index 000000000..1a1777e1e --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/IAppRequestResult.cs @@ -0,0 +1,43 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using System; + using System.Collections.Generic; + + /// + /// App request result. + /// + public interface IAppRequestResult : IResult + { + /// + /// Gets RequestID + /// + /// A request ID assigned by Facebook + string RequestID { get; } + + /// + /// Gets to. + /// + /// An array of string, each element being the Facebook ID of one of the selected recipients. + IEnumerable To { get; } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/IAppRequestResult.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Results/IAppRequestResult.cs.meta new file mode 100644 index 000000000..fb3a1d061 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/IAppRequestResult.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43e4788f73a304c98809fd54d709ca23 +timeCreated: 1438289533 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/IGraphResult.cs b/Facebook.Unity/Assets/Facebook/Scripts/Results/IGraphResult.cs new file mode 100644 index 000000000..4e53c12ed --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/IGraphResult.cs @@ -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. + */ + +namespace Facebook.Unity +{ + using System; + using System.Collections.Generic; + + /// + /// The result of a graph api call. + /// + public interface IGraphResult : IResult + { + /// + /// Gets the result. + /// + /// A list parsed from the result + IList ResultList { get; } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/IGraphResult.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Results/IGraphResult.cs.meta new file mode 100644 index 000000000..4e200decd --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/IGraphResult.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ddefec37cd10e4773ae547b9b3351724 +timeCreated: 1438289533 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/IGroupCreateResult.cs b/Facebook.Unity/Assets/Facebook/Scripts/Results/IGroupCreateResult.cs new file mode 100644 index 000000000..dbc85c690 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/IGroupCreateResult.cs @@ -0,0 +1,34 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + /// + /// The result of a group creation. + /// + public interface IGroupCreateResult : IResult + { + /// + /// Gets or sets the group identifier. + /// + /// The group id of the group created. + string GroupId { get; } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/IGroupCreateResult.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Results/IGroupCreateResult.cs.meta new file mode 100644 index 000000000..abe8d6e3a --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/IGroupCreateResult.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 927f3777fa03f4b1c8128fc71244b390 +timeCreated: 1438289533 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/IGroupJoinResult.cs b/Facebook.Unity/Assets/Facebook/Scripts/Results/IGroupJoinResult.cs new file mode 100644 index 000000000..6db07d05a --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/IGroupJoinResult.cs @@ -0,0 +1,29 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + /// + /// The result of a group join. + /// + public interface IGroupJoinResult : IResult + { + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/IGroupJoinResult.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Results/IGroupJoinResult.cs.meta new file mode 100644 index 000000000..96d03a400 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/IGroupJoinResult.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: efae16d98259f4a939a4e9c2f80eb2a1 +timeCreated: 1438289533 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/IInternalResult.cs b/Facebook.Unity/Assets/Facebook/Scripts/Results/IInternalResult.cs new file mode 100644 index 000000000..708bc178f --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/IInternalResult.cs @@ -0,0 +1,31 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + internal interface IInternalResult : IResult + { + /// + /// Gets the callback identifier. + /// + /// A unique ID for this callback. This value should only be used internally. + string CallbackId { get; } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/IInternalResult.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Results/IInternalResult.cs.meta new file mode 100644 index 000000000..e5a4f9115 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/IInternalResult.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3bd46b9476e1f42c58c4014ad3f2ad92 +timeCreated: 1439935333 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/ILoginResult.cs b/Facebook.Unity/Assets/Facebook/Scripts/Results/ILoginResult.cs new file mode 100644 index 000000000..bc3e60824 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/ILoginResult.cs @@ -0,0 +1,34 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + /// + /// The result of a login request. + /// + public interface ILoginResult : IResult + { + /// + /// Gets the access token. + /// + /// The access token returned from login if successful else null. + AccessToken AccessToken { get; } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/ILoginResult.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Results/ILoginResult.cs.meta new file mode 100644 index 000000000..61d440899 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/ILoginResult.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d2926a486aafc4212880706f935292a2 +timeCreated: 1438289533 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/IPayResult.cs b/Facebook.Unity/Assets/Facebook/Scripts/Results/IPayResult.cs new file mode 100644 index 000000000..f478dd741 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/IPayResult.cs @@ -0,0 +1,29 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + /// + /// The result of a pay request + /// + public interface IPayResult : IResult + { + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/IPayResult.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Results/IPayResult.cs.meta new file mode 100644 index 000000000..d8f4e22bc --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/IPayResult.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 945349bbfb7b54e8298f2d33e1ecc6fa +timeCreated: 1438289533 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/IResult.cs b/Facebook.Unity/Assets/Facebook/Scripts/Results/IResult.cs new file mode 100644 index 000000000..eb2ff3fe9 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/IResult.cs @@ -0,0 +1,55 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using System.Collections; + using System.Collections.Generic; + + /// + /// A result. + /// + public interface IResult + { + /// + /// Gets the error. + /// + /// The error string from the result. If no error occured value is null or empty. + string Error { get; } + + /// + /// Gets the result. + /// + /// A collection of key values pairs that are parsed from the result + IDictionary ResultDictionary { get; } + + /// + /// Gets the raw result. + /// + /// The raw result string. + string RawResult { get; } + + /// + /// Gets a value indicating whether this instance cancelled. + /// + /// true if this instance cancelled; otherwise, false.b + bool Cancelled { get; } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/IResult.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Results/IResult.cs.meta new file mode 100644 index 000000000..f5100da30 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/IResult.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 84aea5651458c412bb6748ce5ae90771 +timeCreated: 1437523161 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/IShareResult.cs b/Facebook.Unity/Assets/Facebook/Scripts/Results/IShareResult.cs new file mode 100644 index 000000000..3c9ca0fc1 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/IShareResult.cs @@ -0,0 +1,34 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + /// + /// The result of a share. + /// + public interface IShareResult : IResult + { + /// + /// Gets the post identifier. + /// + /// The post identifier if the post was successful and the user is tossed. + string PostId { get; } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/IShareResult.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Results/IShareResult.cs.meta new file mode 100644 index 000000000..ded9cda8f --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/IShareResult.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0044d8071c5344b0c9aa204d2093b4d1 +timeCreated: 1438289533 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/LoginResult.cs b/Facebook.Unity/Assets/Facebook/Scripts/Results/LoginResult.cs new file mode 100644 index 000000000..a505714ec --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/LoginResult.cs @@ -0,0 +1,154 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + internal class LoginResult : ResultBase, ILoginResult + { + public static readonly string UserIdKey = Constants.IsWeb ? "userID" : "user_id"; + public static readonly string ExpirationTimestampKey = Constants.IsWeb ? "expiresIn" : "expiration_timestamp"; + public static readonly string PermissionsKey = Constants.IsWeb ? "grantedScopes" : "permissions"; + public static readonly string AccessTokenKey = Constants.IsWeb ? "accessToken" : Constants.AccessTokenKey; + + internal LoginResult(string response) : base(response) + { + if (this.ResultDictionary != null && this.ResultDictionary.ContainsKey(LoginResult.AccessTokenKey)) + { + this.AccessToken = LoginResult.ParseAccessTokenFromResult(this.ResultDictionary); + } + } + + public AccessToken AccessToken { get; private set; } + + private static AccessToken ParseAccessTokenFromResult(IDictionary resultDictionary) + { + string userID = resultDictionary.GetValueOrDefault(LoginResult.UserIdKey); + string accessToken = resultDictionary.GetValueOrDefault(LoginResult.AccessTokenKey); + DateTime expiration = LoginResult.ParseExpirationDateFromResult(resultDictionary); + ICollection permissions = LoginResult.ParsePermissionFromResult(resultDictionary); + + return new AccessToken( + accessToken, + userID, + expiration, + permissions); + } + + private static DateTime ParseExpirationDateFromResult(IDictionary resultDictionary) + { + DateTime expiration; + if (Constants.IsWeb) + { + // For canvas we get back the time as seconds since now instead of in epoch time. + expiration = DateTime.Now.AddSeconds(resultDictionary.GetValueOrDefault(LoginResult.ExpirationTimestampKey)); + } + else + { + string expirationStr = resultDictionary.GetValueOrDefault(LoginResult.ExpirationTimestampKey); + int expiredTimeSeconds; + if (int.TryParse(expirationStr, out expiredTimeSeconds) && expiredTimeSeconds > 0) + { + expiration = LoginResult.FromTimestamp(expiredTimeSeconds); + } + else + { + expiration = DateTime.MaxValue; + } + } + + return expiration; + } + + private static ICollection ParsePermissionFromResult(IDictionary resultDictionary) + { + string permissions; + IEnumerable permissionList; + + // For permissions we can get the result back in either a comma separated string or + // a list depending on the platform. + if (resultDictionary.TryGetValue(LoginResult.PermissionsKey, out permissions)) + { + permissionList = permissions.Split(','); + } + else if (!resultDictionary.TryGetValue(LoginResult.PermissionsKey, out permissionList)) + { + permissionList = new string[0]; + FacebookLogger.Warn("Failed to find parameter '{0}' in login result", LoginResult.PermissionsKey); + } + + return permissionList.Select(permission => permission.ToString()).ToList(); + } + + private static DateTime FromTimestamp(int timestamp) + { + return new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(timestamp); + } + + private AccessToken ParseAccessTokeFromResponse() + { + if (this.ResultDictionary == null || + !this.ResultDictionary.ContainsKey("user_id")) + { + return null; + } + + string userId = (string)this.ResultDictionary["user_id"]; + string accessToken = (string)this.ResultDictionary["access_token"]; + + int expiredTimeSeconds; + DateTime accessTokenExpiresAt; + + // If the date time is very large or 0 assume the token never expires + if (int.TryParse((string)this.ResultDictionary["expiration_timestamp"], out expiredTimeSeconds) && expiredTimeSeconds > 0) + { + accessTokenExpiresAt = FromTimestamp(expiredTimeSeconds); + } + else + { + accessTokenExpiresAt = DateTime.MaxValue; + } + + // Permissions can be array or string + ICollection permissions; + string permissionStr = this.ResultDictionary["permissions"] as string; + if (permissionStr != null) + { + permissions = permissionStr.Split(','); + } + else + { + // Assume we have an list + var rawPermissions = (IEnumerable)this.ResultDictionary["permissions"]; + permissions = rawPermissions.Select(permission => permission.ToString()).ToList(); + } + + return new AccessToken( + accessToken, + userId, + accessTokenExpiresAt, + permissions); + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/LoginResult.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Results/LoginResult.cs.meta new file mode 100644 index 000000000..3e5b473a7 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/LoginResult.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 835dd3398011f40479d7fd29cd4acc39 +timeCreated: 1437511590 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/PayResult.cs b/Facebook.Unity/Assets/Facebook/Scripts/Results/PayResult.cs new file mode 100644 index 000000000..99158fdbb --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/PayResult.cs @@ -0,0 +1,29 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + internal class PayResult : ResultBase, IPayResult + { + internal PayResult(string result) : base(result) + { + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/PayResult.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Results/PayResult.cs.meta new file mode 100644 index 000000000..33fbde6b3 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/PayResult.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3cd20fff9319d49e9a8e7c57338eb004 +timeCreated: 1437596941 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/ResultBase.cs b/Facebook.Unity/Assets/Facebook/Scripts/Results/ResultBase.cs new file mode 100644 index 000000000..f0335a51a --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/ResultBase.cs @@ -0,0 +1,148 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using System; + using System.Collections; + using System.Collections.Generic; + + internal abstract class ResultBase : IInternalResult + { + internal ResultBase(string result) + { + string error = null; + bool cancelled = false; + string callbackId = null; + if (!string.IsNullOrEmpty(result)) + { + var dictionary = Facebook.MiniJSON.Json.Deserialize(result) as Dictionary; + if (dictionary != null) + { + this.ResultDictionary = dictionary; + error = ResultBase.GetErrorValue(dictionary); + cancelled = ResultBase.GetCancelledValue(dictionary); + callbackId = ResultBase.GetCallbackId(dictionary); + } + } + + this.Init(result, error, cancelled, callbackId); + } + + internal ResultBase(string result, string error, bool cancelled) + { + this.Init(result, error, cancelled, null); + } + + public virtual string Error { get; protected set; } + + public virtual IDictionary ResultDictionary { get; protected set; } + + public virtual string RawResult { get; protected set; } + + public virtual bool Cancelled { get; protected set; } + + public virtual string CallbackId { get; protected set; } + + public override string ToString() + { + return string.Format( + "[BaseResult: Error={0}, Result={1}, RawResult={2}, Cancelled={3}]", + this.Error, + this.ResultDictionary, + this.RawResult, + this.Cancelled); + } + + protected void Init(string result, string error, bool cancelled, string callbackId) + { + this.RawResult = result; + this.Cancelled = cancelled; + this.Error = error; + this.CallbackId = callbackId; + } + + private static string GetErrorValue(IDictionary result) + { + if (result == null) + { + return null; + } + + string error; + if (result.TryGetValue("error", out error)) + { + return error; + } + + return null; + } + + private static bool GetCancelledValue(IDictionary result) + { + if (result == null) + { + return false; + } + + // Check for cancel string + object cancelled; + if (result.TryGetValue("cancelled", out cancelled)) + { + bool? cancelBool = cancelled as bool?; + if (cancelBool != null) + { + return cancelBool.HasValue && cancelBool.Value; + } + + string cancelString = cancelled as string; + if (cancelString != null) + { + return Convert.ToBoolean(cancelString); + } + + int? cancelInt = cancelled as int?; + if (cancelInt != null) + { + return cancelInt.HasValue && cancelInt.Value != 0; + } + } + + return false; + } + + private static string GetCallbackId(IDictionary result) + { + if (result == null) + { + return null; + } + + // Check for cancel string + string callbackId; + if (result.TryGetValue(Constants.CallbackIdKey, out callbackId)) + { + return callbackId; + } + + return null; + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/ResultBase.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Results/ResultBase.cs.meta new file mode 100644 index 000000000..d30906f91 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/ResultBase.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 896eac851e1274000bdbcd94212dd309 +timeCreated: 1439327577 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/ShareResult.cs b/Facebook.Unity/Assets/Facebook/Scripts/Results/ShareResult.cs new file mode 100644 index 000000000..72c928bdd --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/ShareResult.cs @@ -0,0 +1,42 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using System; + using System.Collections; + + internal class ShareResult : ResultBase, IShareResult + { + internal ShareResult(string result) : base(result) + { + if (this.ResultDictionary != null) + { + object postId; + if (this.ResultDictionary.TryGetValue("id", out postId)) + { + this.PostId = postId as string; + } + } + } + + public string PostId { get; private set; } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Results/ShareResult.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Results/ShareResult.cs.meta new file mode 100644 index 000000000..00161fb6e --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Results/ShareResult.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 81fde01e8828e4149a89c3702c3607fc +timeCreated: 1437585803 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Utils.meta b/Facebook.Unity/Assets/Facebook/Scripts/Utils.meta new file mode 100644 index 000000000..7a20ef3a5 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Utils.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: ca2fa0d66c0914aeb8d42a093b292069 +folderAsset: yes +timeCreated: 1432149545 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Utils/AsyncRequestString.cs b/Facebook.Unity/Assets/Facebook/Scripts/Utils/AsyncRequestString.cs new file mode 100644 index 000000000..b4fc2a012 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Utils/AsyncRequestString.cs @@ -0,0 +1,163 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using System; + using System.Collections; + using System.Collections.Generic; + using UnityEngine; + + /* + * A short lived async request that loads a FBResult from a url endpoint + */ + internal class AsyncRequestString : MonoBehaviour + { + private string url; + private HttpMethod method; + private IDictionary formData; + private WWWForm query; + private FacebookDelegate callback; + + internal static void Post( + string url, + Dictionary formData = null, + FacebookDelegate callback = null) + { + Request(url, HttpMethod.POST, formData, callback); + } + + internal static void Get( + string url, + Dictionary formData = null, + FacebookDelegate callback = null) + { + Request(url, HttpMethod.GET, formData, callback); + } + + internal static void Request( + string url, + HttpMethod method, + WWWForm query = null, + FacebookDelegate callback = null) + { + ComponentFactory.AddComponent() + .SetUrl(url) + .SetMethod(method) + .SetQuery(query) + .SetCallback(callback); + } + + internal static void Request( + string url, + HttpMethod method, + IDictionary formData = null, + FacebookDelegate callback = null) + { + ComponentFactory.AddComponent() + .SetUrl(url) + .SetMethod(method) + .SetFormData(formData) + .SetCallback(callback); + } + + internal IEnumerator Start() + { + WWW www; + if (this.method == HttpMethod.GET) + { + string urlParams = this.url.Contains("?") ? "&" : "?"; + if (this.formData != null) + { + foreach (KeyValuePair pair in this.formData) + { + urlParams += string.Format("{0}={1}&", Uri.EscapeDataString(pair.Key), Uri.EscapeDataString(pair.Value)); + } + } + + www = new WWW(this.url + urlParams); + } + else + { + // POST or DELETE + if (this.query == null) + { + this.query = new WWWForm(); + } + + if (this.method == HttpMethod.DELETE) + { + this.query.AddField("method", "delete"); + } + + if (this.formData != null) + { + foreach (KeyValuePair pair in this.formData) + { + this.query.AddField(pair.Key, pair.Value); + } + } + + www = new WWW(this.url, this.query); + } + + yield return www; + + if (this.callback != null) + { + this.callback(new GraphResult(www)); + } + + // after the callback is called, www should be able to be disposed + www.Dispose(); + MonoBehaviour.Destroy(this); + } + + internal AsyncRequestString SetUrl(string url) + { + this.url = url; + return this; + } + + internal AsyncRequestString SetMethod(HttpMethod method) + { + this.method = method; + return this; + } + + internal AsyncRequestString SetFormData(IDictionary formData) + { + this.formData = formData; + return this; + } + + internal AsyncRequestString SetQuery(WWWForm query) + { + this.query = query; + return this; + } + + internal AsyncRequestString SetCallback(FacebookDelegate callback) + { + this.callback = callback; + return this; + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Utils/AsyncRequestString.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Utils/AsyncRequestString.cs.meta new file mode 100644 index 000000000..7e481662b --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Utils/AsyncRequestString.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f26f7513492a55c4fb66be6383b87c12 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Utils/FacebookLogger.cs b/Facebook.Unity/Assets/Facebook/Scripts/Utils/FacebookLogger.cs new file mode 100644 index 000000000..f06d5a274 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Utils/FacebookLogger.cs @@ -0,0 +1,225 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using Facebook.Unity.Mobile.Android; + using UnityEngine; + + internal static class FacebookLogger + { + private const string UnityAndroidTag = "Facebook.Unity.FBDebug"; + + static FacebookLogger() + { + FacebookLogger.Instance = new CustomLogger(); + } + + internal static IFacebookLogger Instance { private get; set; } + + public static void Log(string msg) + { + FacebookLogger.Instance.Log(msg); + } + + public static void Log(string format, params string[] args) + { + FacebookLogger.Log(string.Format(format, args)); + } + + public static void Info(string msg) + { + FacebookLogger.Instance.Info(msg); + } + + public static void Info(string format, params string[] args) + { + FacebookLogger.Info(string.Format(format, args)); + } + + public static void Warn(string msg) + { + FacebookLogger.Instance.Warn(msg); + } + + public static void Warn(string format, params string[] args) + { + FacebookLogger.Warn(string.Format(format, args)); + } + + public static void Error(string msg) + { + FacebookLogger.Instance.Error(msg); + } + + public static void Error(string format, params string[] args) + { + FacebookLogger.Error(string.Format(format, args)); + } + + private class CustomLogger : IFacebookLogger + { + private IFacebookLogger logger; + + public CustomLogger() + { +#if UNITY_EDITOR + this.logger = new EditorLogger(); +#elif UNITY_ANDROID + this.logger = new AndroidLogger(); +#elif UNITY_IOS + this.logger = new IOSLogger(); +#else + this.logger = new CanvasLogger(); +#endif + } + + public void Log(string msg) + { + if (Debug.isDebugBuild) + { + Debug.Log(msg); + this.logger.Log(msg); + } + } + + public void Info(string msg) + { + Debug.Log(msg); + this.logger.Info(msg); + } + + public void Warn(string msg) + { + Debug.LogWarning(msg); + this.logger.Warn(msg); + } + + public void Error(string msg) + { + Debug.LogError(msg); + this.logger.Error(msg); + } + } + +#if UNITY_EDITOR + private class EditorLogger : IFacebookLogger + { + public void Log(string msg) + { + } + + public void Info(string msg) + { + } + + public void Warn(string msg) + { + } + + public void Error(string msg) + { + } + } + +#elif UNITY_ANDROID + private class AndroidLogger : IFacebookLogger + { + public void Log(string msg) + { + using (AndroidJavaClass androidLogger = new AndroidJavaClass("android.util.Log")) + { + androidLogger.CallStatic("v", UnityAndroidTag, msg); + } + } + + public void Info(string msg) + { + using (AndroidJavaClass androidLogger = new AndroidJavaClass("android.util.Log")) + { + androidLogger.CallStatic("i", UnityAndroidTag, msg); + } + } + + public void Warn(string msg) + { + using (AndroidJavaClass androidLogger = new AndroidJavaClass("android.util.Log")) + { + androidLogger.CallStatic("w", UnityAndroidTag, msg); + } + } + + public void Error(string msg) + { + using (AndroidJavaClass androidLogger = new AndroidJavaClass("android.util.Log")) + { + androidLogger.CallStatic("e", UnityAndroidTag, msg); + } + } + } +#elif UNITY_IOS + private class IOSLogger: IFacebookLogger + { + public void Log(string msg) + { + // TODO + } + + public void Info(string msg) + { + // TODO + } + + public void Warn(string msg) + { + // TODO + } + + public void Error(string msg) + { + // TODO + } + } +#else + private class CanvasLogger : IFacebookLogger + { + public void Log(string msg) + { + Application.ExternalCall("console.log", msg); + } + + public void Info(string msg) + { + Application.ExternalCall("console.info", msg); + } + + public void Warn(string msg) + { + Application.ExternalCall("console.warn", msg); + } + + public void Error(string msg) + { + Application.ExternalCall("console.error", msg); + } + } +#endif + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Utils/FacebookLogger.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Utils/FacebookLogger.cs.meta new file mode 100644 index 000000000..74ecf208f --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Utils/FacebookLogger.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1d96f06149d5e4380827ddd013315e54 +timeCreated: 1438298352 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Utils/HttpMethod.cs b/Facebook.Unity/Assets/Facebook/Scripts/Utils/HttpMethod.cs new file mode 100644 index 000000000..79b69ed23 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Utils/HttpMethod.cs @@ -0,0 +1,43 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + /// + /// Http method. + /// + public enum HttpMethod + { + /// + /// Indicates that the request is a GET request. + /// + GET, + + /// + /// Indicates that the request is a POST request. + /// + POST, + + /// + /// Indicates that the request is a DELETE request. + /// + DELETE, + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Utils/HttpMethod.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Utils/HttpMethod.cs.meta new file mode 100644 index 000000000..ea6064e81 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Utils/HttpMethod.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0a1d6895865a7b64ba0b2115de038760 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Utils/IFacebookLogger.cs b/Facebook.Unity/Assets/Facebook/Scripts/Utils/IFacebookLogger.cs new file mode 100644 index 000000000..bc113dc4b --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Utils/IFacebookLogger.cs @@ -0,0 +1,33 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + internal interface IFacebookLogger + { + void Log(string msg); + + void Info(string msg); + + void Warn(string msg); + + void Error(string msg); + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Utils/IFacebookLogger.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Utils/IFacebookLogger.cs.meta new file mode 100644 index 000000000..5de3a2553 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Utils/IFacebookLogger.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 77848c6dc74ce484daaae13f75434567 +timeCreated: 1439928982 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Utils/MiniJson.cs b/Facebook.Unity/Assets/Facebook/Scripts/Utils/MiniJson.cs new file mode 100644 index 000000000..c39789431 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Utils/MiniJson.cs @@ -0,0 +1,624 @@ +/* + * Copyright (c) 2012 Calvin Rien + * + * Based on the JSON parser by Patrick van Bergen + * http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html + * + * Simplified it so that it doesn't throw exceptions + * and can be used in Unity iPhone with maximum code stripping. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission 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. + */ + +namespace Facebook.MiniJSON +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Globalization; + using System.IO; + using System.Text; + + // Example usage: + // + // using UnityEngine; + // using System.Collections; + // using System.Collections.Generic; + // using MiniJSON; + // + // public class MiniJSONTest : MonoBehaviour { + // void Start () { + // var jsonString = "{ \"array\": [1.44,2,3], " + + // "\"object\": {\"key1\":\"value1\", \"key2\":256}, " + + // "\"string\": \"The quick brown fox \\\"jumps\\\" over the lazy dog \", " + + // "\"unicode\": \"\\u3041 Men\u00fa sesi\u00f3n\", " + + // "\"int\": 65536, " + + // "\"float\": 3.1415926, " + + // "\"bool\": true, " + + // "\"null\": null }"; + // + // var dict = Json.Deserialize(jsonString) as Dictionary; + // + // Debug.Log("deserialized: " + dict.GetType()); + // Debug.Log("dict['array'][0]: " + ((List) dict["array"])[0]); + // Debug.Log("dict['string']: " + (string) dict["string"]); + // Debug.Log("dict['float']: " + (double) dict["float"]); // floats come out as doubles + // Debug.Log("dict['int']: " + (long) dict["int"]); // ints come out as longs + // Debug.Log("dict['unicode']: " + (string) dict["unicode"]); + // + // var str = Json.Serialize(dict); + // + // Debug.Log("serialized: " + str); + // } + // } + + /// + /// This class encodes and decodes JSON strings. + /// Spec. details, see http://www.json.org/ + /// + /// JSON uses Arrays and Objects. These correspond here to the datatypes IList and IDictionary. + /// All numbers are parsed to doubles. + /// + public static class Json + { + // interpret all numbers as if they are english US formatted numbers + private static NumberFormatInfo numberFormat = (new CultureInfo("en-US")).NumberFormat; + + /// + /// Parses the string json into a value + /// + /// A JSON string. + /// An List<object>, a Dictionary<string, object>, a double, an integer,a string, null, true, or false + public static object Deserialize(string json) + { + // save the string for debug information + if (json == null) + { + return null; + } + + return Parser.Parse(json); + } + + /// + /// Converts a IDictionary / IList object or a simple type (string, int, etc.) into a JSON string + /// + /// A Dictionary<string, object> / List<object> + /// A JSON encoded string, or null if object 'json' is not serializable + public static string Serialize(object obj) + { + return Serializer.Serialize(obj); + } + + private sealed class Parser : IDisposable + { + private const string WhiteSpace = " \t\n\r"; + private const string WordBreak = " \t\n\r{}[],:\""; + + private StringReader json; + + private Parser(string jsonString) + { + this.json = new StringReader(jsonString); + } + + private enum TOKEN + { + NONE, + CURLY_OPEN, + CURLY_CLOSE, + SQUARED_OPEN, + SQUARED_CLOSE, + COLON, + COMMA, + STRING, + NUMBER, + TRUE, + FALSE, + NULL + } + + private char PeekChar + { + get + { + return Convert.ToChar(this.json.Peek()); + } + } + + private char NextChar + { + get + { + return Convert.ToChar(this.json.Read()); + } + } + + private string NextWord + { + get + { + StringBuilder word = new StringBuilder(); + + while (WordBreak.IndexOf(this.PeekChar) == -1) + { + word.Append(this.NextChar); + + if (this.json.Peek() == -1) + { + break; + } + } + + return word.ToString(); + } + } + + private TOKEN NextToken + { + get + { + this.EatWhitespace(); + + if (this.json.Peek() == -1) + { + return TOKEN.NONE; + } + + char c = this.PeekChar; + switch (c) + { + case '{': + return TOKEN.CURLY_OPEN; + case '}': + this.json.Read(); + return TOKEN.CURLY_CLOSE; + case '[': + return TOKEN.SQUARED_OPEN; + case ']': + this.json.Read(); + return TOKEN.SQUARED_CLOSE; + case ',': + this.json.Read(); + return TOKEN.COMMA; + case '"': + return TOKEN.STRING; + case ':': + return TOKEN.COLON; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '-': + return TOKEN.NUMBER; + } + + string word = this.NextWord; + + switch (word) + { + case "false": + return TOKEN.FALSE; + case "true": + return TOKEN.TRUE; + case "null": + return TOKEN.NULL; + } + + return TOKEN.NONE; + } + } + + public static object Parse(string jsonString) + { + using (var instance = new Parser(jsonString)) + { + return instance.ParseValue(); + } + } + + public void Dispose() + { + this.json.Dispose(); + this.json = null; + } + + private Dictionary ParseObject() + { + Dictionary table = new Dictionary(); + + // ditch opening brace + this.json.Read(); + + // { + while (true) + { + switch (this.NextToken) + { + case TOKEN.NONE: + return null; + case TOKEN.COMMA: + continue; + case TOKEN.CURLY_CLOSE: + return table; + default: + // name + string name = this.ParseString(); + if (name == null) + { + return null; + } + + // : + if (this.NextToken != TOKEN.COLON) + { + return null; + } + + // ditch the colon + this.json.Read(); + + // value + table[name] = this.ParseValue(); + break; + } + } + } + + private List ParseArray() + { + List array = new List(); + + // ditch opening bracket + this.json.Read(); + + // [ + var parsing = true; + while (parsing) + { + TOKEN nextToken = this.NextToken; + + switch (nextToken) + { + case TOKEN.NONE: + return null; + case TOKEN.COMMA: + continue; + case TOKEN.SQUARED_CLOSE: + parsing = false; + break; + default: + object value = this.ParseByToken(nextToken); + + array.Add(value); + break; + } + } + + return array; + } + + private object ParseValue() + { + TOKEN nextToken = this.NextToken; + return this.ParseByToken(nextToken); + } + + private object ParseByToken(TOKEN token) + { + switch (token) + { + case TOKEN.STRING: + return this.ParseString(); + case TOKEN.NUMBER: + return this.ParseNumber(); + case TOKEN.CURLY_OPEN: + return this.ParseObject(); + case TOKEN.SQUARED_OPEN: + return this.ParseArray(); + case TOKEN.TRUE: + return true; + case TOKEN.FALSE: + return false; + case TOKEN.NULL: + return null; + default: + return null; + } + } + + private string ParseString() + { + StringBuilder s = new StringBuilder(); + char c; + + // ditch opening quote + this.json.Read(); + + bool parsing = true; + while (parsing) + { + if (this.json.Peek() == -1) + { + parsing = false; + break; + } + + c = this.NextChar; + switch (c) + { + case '"': + parsing = false; + break; + case '\\': + if (this.json.Peek() == -1) + { + parsing = false; + break; + } + + c = this.NextChar; + switch (c) + { + case '"': + case '\\': + case '/': + s.Append(c); + break; + case 'b': + s.Append('\b'); + break; + case 'f': + s.Append('\f'); + break; + case 'n': + s.Append('\n'); + break; + case 'r': + s.Append('\r'); + break; + case 't': + s.Append('\t'); + break; + case 'u': + var hex = new StringBuilder(); + + for (int i = 0; i < 4; i++) + { + hex.Append(this.NextChar); + } + + s.Append((char)Convert.ToInt32(hex.ToString(), 16)); + break; + } + + break; + default: + s.Append(c); + break; + } + } + + return s.ToString(); + } + + private object ParseNumber() + { + string number = this.NextWord; + + if (number.IndexOf('.') == -1) + { + return long.Parse(number, numberFormat); + } + + return double.Parse(number, numberFormat); + } + + private void EatWhitespace() + { + while (WhiteSpace.IndexOf(this.PeekChar) != -1) + { + this.json.Read(); + + if (this.json.Peek() == -1) + { + break; + } + } + } + } + + private sealed class Serializer + { + private StringBuilder builder; + + private Serializer() + { + this.builder = new StringBuilder(); + } + + public static string Serialize(object obj) + { + var instance = new Serializer(); + + instance.SerializeValue(obj); + + return instance.builder.ToString(); + } + + private void SerializeValue(object value) + { + IList asList; + IDictionary asDict; + string asStr; + + if (value == null) + { + this.builder.Append("null"); + } + else if ((asStr = value as string) != null) + { + this.SerializeString(asStr); + } + else if (value is bool) + { + this.builder.Append(value.ToString().ToLower()); + } + else if ((asList = value as IList) != null) + { + this.SerializeArray(asList); + } + else if ((asDict = value as IDictionary) != null) + { + this.SerializeObject(asDict); + } + else if (value is char) + { + this.SerializeString(value.ToString()); + } + else + { + this.SerializeOther(value); + } + } + + private void SerializeObject(IDictionary obj) + { + bool first = true; + + this.builder.Append('{'); + + foreach (object e in obj.Keys) + { + if (!first) + { + this.builder.Append(','); + } + + this.SerializeString(e.ToString()); + this.builder.Append(':'); + + this.SerializeValue(obj[e]); + + first = false; + } + + this.builder.Append('}'); + } + + private void SerializeArray(IList array) + { + this.builder.Append('['); + + bool first = true; + + foreach (object obj in array) + { + if (!first) + { + this.builder.Append(','); + } + + this.SerializeValue(obj); + + first = false; + } + + this.builder.Append(']'); + } + + private void SerializeString(string str) + { + this.builder.Append('\"'); + + char[] charArray = str.ToCharArray(); + foreach (var c in charArray) + { + switch (c) + { + case '"': + this.builder.Append("\\\""); + break; + case '\\': + this.builder.Append("\\\\"); + break; + case '\b': + this.builder.Append("\\b"); + break; + case '\f': + this.builder.Append("\\f"); + break; + case '\n': + this.builder.Append("\\n"); + break; + case '\r': + this.builder.Append("\\r"); + break; + case '\t': + this.builder.Append("\\t"); + break; + default: + int codepoint = Convert.ToInt32(c); + if ((codepoint >= 32) && (codepoint <= 126)) + { + this.builder.Append(c); + } + else + { + this.builder.Append("\\u" + Convert.ToString(codepoint, 16).PadLeft(4, '0')); + } + + break; + } + } + + this.builder.Append('\"'); + } + + private void SerializeOther(object value) + { + if (value is float + || value is int + || value is uint + || value is long + || value is double + || value is sbyte + || value is byte + || value is short + || value is ushort + || value is ulong + || value is decimal) + { + this.builder.Append(value.ToString()); + } + else + { + this.SerializeString(value.ToString()); + } + } + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Utils/MiniJson.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Utils/MiniJson.cs.meta new file mode 100644 index 000000000..09720fe67 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Utils/MiniJson.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9c6519a324d87d24b85073cad7605df3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Utils/Utilities.cs b/Facebook.Unity/Assets/Facebook/Scripts/Utils/Utilities.cs new file mode 100644 index 000000000..11d6d22be --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Utils/Utilities.cs @@ -0,0 +1,89 @@ +/** + * 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. + */ + +namespace Facebook.Unity +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + internal static class Utilities + { + private const string WarningMissingParameter = "Did not find expected value '{0}' in dictionary"; + + public static bool TryGetValue( + this IDictionary dictionary, + string key, + out T value) + { + object resultObj; + if (dictionary.TryGetValue(key, out resultObj) && resultObj is T) + { + value = (T)resultObj; + return true; + } + + value = default(T); + return false; + } + + public static long TotalSeconds(this DateTime dateTime) + { + TimeSpan t = dateTime - new DateTime(1970, 1, 1); + long secondsSinceEpoch = (long)t.TotalSeconds; + return secondsSinceEpoch; + } + + public static T GetValueOrDefault( + this IDictionary dictionary, + string key, + bool logWarning = true) + { + T result; + if (!dictionary.TryGetValue(key, out result)) + { + FacebookLogger.Warn(WarningMissingParameter, key); + } + + return result; + } + + public static string ToCommaSeparateList(this IEnumerable list) + { + if (list == null) + { + return string.Empty; + } + + return string.Join(",", list.ToArray()); + } + + public static string AbsoluteUrlOrEmptyString(this Uri uri) + { + if (uri == null) + { + return string.Empty; + } + + return uri.AbsoluteUri; + } + } +} diff --git a/Facebook.Unity/Assets/Facebook/Scripts/Utils/Utilities.cs.meta b/Facebook.Unity/Assets/Facebook/Scripts/Utils/Utilities.cs.meta new file mode 100644 index 000000000..026742473 --- /dev/null +++ b/Facebook.Unity/Assets/Facebook/Scripts/Utils/Utilities.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ea63d69f4908c40f49c3d09527247182 +timeCreated: 1438027480 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/FacebookMeta.meta b/Facebook.Unity/Assets/FacebookMeta.meta new file mode 100644 index 000000000..e1be829fa --- /dev/null +++ b/Facebook.Unity/Assets/FacebookMeta.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 258d61fb4a41bee41b6d75355367208a +folderAsset: yes +DefaultImporter: + userData: diff --git a/Facebook.Unity/Assets/FacebookTest.meta b/Facebook.Unity/Assets/FacebookTest.meta new file mode 100644 index 000000000..c13799efe --- /dev/null +++ b/Facebook.Unity/Assets/FacebookTest.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 94aa613dd53f7884a93a296c57d60cdf +folderAsset: yes +DefaultImporter: + userData: diff --git a/Facebook.Unity/Assets/Plugins.meta b/Facebook.Unity/Assets/Plugins.meta new file mode 100644 index 000000000..6b71c6c8f --- /dev/null +++ b/Facebook.Unity/Assets/Plugins.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: b78e4c99579bdbb448891f376427290b +folderAsset: yes +DefaultImporter: + userData: diff --git a/Facebook.Unity/Assets/Plugins/Android.meta b/Facebook.Unity/Assets/Plugins/Android.meta new file mode 100644 index 000000000..dd5506d8c --- /dev/null +++ b/Facebook.Unity/Assets/Plugins/Android.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5b5bb2bc0deae45788c76ea6dc85b02f +folderAsset: yes +timeCreated: 1441062154 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Plugins/iOS.meta b/Facebook.Unity/Assets/Plugins/iOS.meta new file mode 100644 index 000000000..65655c0f5 --- /dev/null +++ b/Facebook.Unity/Assets/Plugins/iOS.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 3bb671414ea424d2cbe8cae6ea9db8cf +folderAsset: yes +timeCreated: 1441062154 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/Assets/Resources.meta b/Facebook.Unity/Assets/Resources.meta new file mode 100644 index 000000000..c79c32272 --- /dev/null +++ b/Facebook.Unity/Assets/Resources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 0e2c9682845424d7aad9d1e0ea0266f6 +folderAsset: yes +timeCreated: 1438802106 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Facebook.Unity/ProjectSettings/AudioManager.asset b/Facebook.Unity/ProjectSettings/AudioManager.asset new file mode 100644 index 000000000..933246a74 --- /dev/null +++ b/Facebook.Unity/ProjectSettings/AudioManager.asset @@ -0,0 +1,11 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!11 &1 +AudioManager: + m_ObjectHideFlags: 0 + m_Volume: 1 + Rolloff Scale: 1 + m_SpeedOfSound: 347 + Doppler Factor: 1 + Default Speaker Mode: 2 + m_DSPBufferSize: 0 diff --git a/Facebook.Unity/ProjectSettings/DynamicsManager.asset b/Facebook.Unity/ProjectSettings/DynamicsManager.asset new file mode 100644 index 000000000..717b5c27a --- /dev/null +++ b/Facebook.Unity/ProjectSettings/DynamicsManager.asset @@ -0,0 +1,15 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!55 &1 +PhysicsManager: + m_ObjectHideFlags: 0 + m_Gravity: {x: 0, y: -9.81000042, z: 0} + m_DefaultMaterial: {fileID: 0} + m_BounceThreshold: 2 + m_SleepVelocity: .150000006 + m_SleepAngularVelocity: .140000001 + m_MaxAngularVelocity: 7 + m_MinPenetrationForPenalty: .00999999978 + m_SolverIterationCount: 6 + m_RaycastsHitTriggers: 1 + m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff diff --git a/Facebook.Unity/ProjectSettings/EditorBuildSettings.asset b/Facebook.Unity/ProjectSettings/EditorBuildSettings.asset new file mode 100644 index 000000000..05e3e6799 --- /dev/null +++ b/Facebook.Unity/ProjectSettings/EditorBuildSettings.asset @@ -0,0 +1,27 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1045 &1 +EditorBuildSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Scenes: + - enabled: 1 + path: Assets/Examples/MainMenu.unity + - enabled: 1 + path: Assets/Examples/AppEvents.unity + - enabled: 1 + path: Assets/Examples/AppRequests.unity + - enabled: 1 + path: Assets/Examples/DialogShare.unity + - enabled: 1 + path: Assets/Examples/GameGroups.unity + - enabled: 1 + path: Assets/Examples/GraphRequest.unity + - enabled: 1 + path: Assets/Examples/LogView.unity + - enabled: 1 + path: Assets/Examples/AppLinks.unity + - enabled: 1 + path: Assets/Examples/AppInvites.unity + - enabled: 1 + path: Assets/Examples/Pay.unity diff --git a/Facebook.Unity/ProjectSettings/EditorSettings.asset b/Facebook.Unity/ProjectSettings/EditorSettings.asset new file mode 100644 index 000000000..63cabb583 --- /dev/null +++ b/Facebook.Unity/ProjectSettings/EditorSettings.asset @@ -0,0 +1,10 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!159 &1 +EditorSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_ExternalVersionControlSupport: Meta Files + m_SerializationMode: 2 + m_WebSecurityEmulationEnabled: 0 + m_WebSecurityEmulationHostUrl: http://www.mydomain.com/mygame.unity3d diff --git a/Facebook.Unity/ProjectSettings/GraphicsSettings.asset b/Facebook.Unity/ProjectSettings/GraphicsSettings.asset new file mode 100644 index 000000000..280a9fdcb --- /dev/null +++ b/Facebook.Unity/ProjectSettings/GraphicsSettings.asset @@ -0,0 +1,29 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!30 &1 +GraphicsSettings: + m_ObjectHideFlags: 0 + serializedVersion: 3 + m_Deferred: + m_Mode: 1 + m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} + m_LegacyDeferred: + m_Mode: 1 + m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} + m_AlwaysIncludedShaders: + - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0} + m_PreloadedShaders: [] + m_LightmapStripping: 0 + m_LightmapKeepPlain: 1 + m_LightmapKeepDirCombined: 1 + m_LightmapKeepDirSeparate: 1 + m_LightmapKeepDynamic: 1 + m_FogStripping: 0 + m_FogKeepLinear: 1 + m_FogKeepExp: 1 + m_FogKeepExp2: 1 diff --git a/Facebook.Unity/ProjectSettings/InputManager.asset b/Facebook.Unity/ProjectSettings/InputManager.asset new file mode 100644 index 000000000..c95d27bd2 --- /dev/null +++ b/Facebook.Unity/ProjectSettings/InputManager.asset @@ -0,0 +1,246 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: .00100000005 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left cmd + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: .100000001 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: .189999998 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: .00100000005 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 diff --git a/Facebook.Unity/ProjectSettings/NavMeshAreas.asset b/Facebook.Unity/ProjectSettings/NavMeshAreas.asset new file mode 100644 index 000000000..79cb3ae98 --- /dev/null +++ b/Facebook.Unity/ProjectSettings/NavMeshAreas.asset @@ -0,0 +1,133 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!126 &1 +NavMeshLayers: + m_ObjectHideFlags: 0 + Built-in Layer 0: + name: Default + cost: 1 + editType: 2 + Built-in Layer 1: + name: Not Walkable + cost: 1 + editType: 0 + Built-in Layer 2: + name: Jump + cost: 2 + editType: 2 + User Layer 0: + name: + cost: 1 + editType: 3 + User Layer 1: + name: + cost: 1 + editType: 3 + User Layer 2: + name: + cost: 1 + editType: 3 + User Layer 3: + name: + cost: 1 + editType: 3 + User Layer 4: + name: + cost: 1 + editType: 3 + User Layer 5: + name: + cost: 1 + editType: 3 + User Layer 6: + name: + cost: 1 + editType: 3 + User Layer 7: + name: + cost: 1 + editType: 3 + User Layer 8: + name: + cost: 1 + editType: 3 + User Layer 9: + name: + cost: 1 + editType: 3 + User Layer 10: + name: + cost: 1 + editType: 3 + User Layer 11: + name: + cost: 1 + editType: 3 + User Layer 12: + name: + cost: 1 + editType: 3 + User Layer 13: + name: + cost: 1 + editType: 3 + User Layer 14: + name: + cost: 1 + editType: 3 + User Layer 15: + name: + cost: 1 + editType: 3 + User Layer 16: + name: + cost: 1 + editType: 3 + User Layer 17: + name: + cost: 1 + editType: 3 + User Layer 18: + name: + cost: 1 + editType: 3 + User Layer 19: + name: + cost: 1 + editType: 3 + User Layer 20: + name: + cost: 1 + editType: 3 + User Layer 21: + name: + cost: 1 + editType: 3 + User Layer 22: + name: + cost: 1 + editType: 3 + User Layer 23: + name: + cost: 1 + editType: 3 + User Layer 24: + name: + cost: 1 + editType: 3 + User Layer 25: + name: + cost: 1 + editType: 3 + User Layer 26: + name: + cost: 1 + editType: 3 + User Layer 27: + name: + cost: 1 + editType: 3 + User Layer 28: + name: + cost: 1 + editType: 3 diff --git a/Facebook.Unity/ProjectSettings/NavMeshLayers.asset b/Facebook.Unity/ProjectSettings/NavMeshLayers.asset new file mode 100644 index 000000000..79cb3ae98 --- /dev/null +++ b/Facebook.Unity/ProjectSettings/NavMeshLayers.asset @@ -0,0 +1,133 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!126 &1 +NavMeshLayers: + m_ObjectHideFlags: 0 + Built-in Layer 0: + name: Default + cost: 1 + editType: 2 + Built-in Layer 1: + name: Not Walkable + cost: 1 + editType: 0 + Built-in Layer 2: + name: Jump + cost: 2 + editType: 2 + User Layer 0: + name: + cost: 1 + editType: 3 + User Layer 1: + name: + cost: 1 + editType: 3 + User Layer 2: + name: + cost: 1 + editType: 3 + User Layer 3: + name: + cost: 1 + editType: 3 + User Layer 4: + name: + cost: 1 + editType: 3 + User Layer 5: + name: + cost: 1 + editType: 3 + User Layer 6: + name: + cost: 1 + editType: 3 + User Layer 7: + name: + cost: 1 + editType: 3 + User Layer 8: + name: + cost: 1 + editType: 3 + User Layer 9: + name: + cost: 1 + editType: 3 + User Layer 10: + name: + cost: 1 + editType: 3 + User Layer 11: + name: + cost: 1 + editType: 3 + User Layer 12: + name: + cost: 1 + editType: 3 + User Layer 13: + name: + cost: 1 + editType: 3 + User Layer 14: + name: + cost: 1 + editType: 3 + User Layer 15: + name: + cost: 1 + editType: 3 + User Layer 16: + name: + cost: 1 + editType: 3 + User Layer 17: + name: + cost: 1 + editType: 3 + User Layer 18: + name: + cost: 1 + editType: 3 + User Layer 19: + name: + cost: 1 + editType: 3 + User Layer 20: + name: + cost: 1 + editType: 3 + User Layer 21: + name: + cost: 1 + editType: 3 + User Layer 22: + name: + cost: 1 + editType: 3 + User Layer 23: + name: + cost: 1 + editType: 3 + User Layer 24: + name: + cost: 1 + editType: 3 + User Layer 25: + name: + cost: 1 + editType: 3 + User Layer 26: + name: + cost: 1 + editType: 3 + User Layer 27: + name: + cost: 1 + editType: 3 + User Layer 28: + name: + cost: 1 + editType: 3 diff --git a/Facebook.Unity/ProjectSettings/NetworkManager.asset b/Facebook.Unity/ProjectSettings/NetworkManager.asset new file mode 100644 index 000000000..5dc6a831d --- /dev/null +++ b/Facebook.Unity/ProjectSettings/NetworkManager.asset @@ -0,0 +1,8 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!149 &1 +NetworkManager: + m_ObjectHideFlags: 0 + m_DebugLevel: 0 + m_Sendrate: 15 + m_AssetToPrefab: {} diff --git a/Facebook.Unity/ProjectSettings/Physics2DSettings.asset b/Facebook.Unity/ProjectSettings/Physics2DSettings.asset new file mode 100644 index 000000000..5418c583e --- /dev/null +++ b/Facebook.Unity/ProjectSettings/Physics2DSettings.asset @@ -0,0 +1,24 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!19 &1 +Physics2DSettings: + m_ObjectHideFlags: 0 + m_Gravity: {x: 0, y: -9.81000042} + m_DefaultMaterial: {fileID: 0} + m_VelocityIterations: 8 + m_PositionIterations: 3 + m_VelocityThreshold: 1 + m_MaxLinearCorrection: .200000003 + m_MaxAngularCorrection: 8 + m_MaxTranslationSpeed: 100 + m_MaxRotationSpeed: 360 + m_MinPenetrationForPenalty: .00999999978 + m_BaumgarteScale: .200000003 + m_BaumgarteTimeOfImpactScale: .75 + m_TimeToSleep: .5 + m_LinearSleepTolerance: .00999999978 + m_AngularSleepTolerance: 2 + m_RaycastsHitTriggers: 1 + m_RaycastsStartInColliders: 1 + m_ChangeStopsCallbacks: 0 + m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff diff --git a/Facebook.Unity/ProjectSettings/ProjectSettings.asset b/Facebook.Unity/ProjectSettings/ProjectSettings.asset new file mode 100644 index 000000000..6d4c59587 --- /dev/null +++ b/Facebook.Unity/ProjectSettings/ProjectSettings.asset @@ -0,0 +1,463 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!129 &1 +PlayerSettings: + m_ObjectHideFlags: 0 + serializedVersion: 7 + AndroidProfiler: 0 + defaultScreenOrientation: 4 + targetDevice: 2 + targetResolution: 0 + accelerometerFrequency: 60 + companyName: Facebook + productName: SDKPackage + defaultCursor: {fileID: 0} + cursorHotspot: {x: 0, y: 0} + m_ShowUnitySplashScreen: 1 + defaultScreenWidth: 1024 + defaultScreenHeight: 768 + defaultScreenWidthWeb: 960 + defaultScreenHeightWeb: 600 + m_RenderingPath: 1 + m_MobileRenderingPath: 1 + m_ActiveColorSpace: 0 + m_MTRendering: 1 + m_MobileMTRendering: 0 + m_Stereoscopic3D: 0 + iosShowActivityIndicatorOnLoading: -1 + androidShowActivityIndicatorOnLoading: -1 + iosAppInBackgroundBehavior: 0 + displayResolutionDialog: 1 + allowedAutorotateToPortrait: 1 + allowedAutorotateToPortraitUpsideDown: 1 + allowedAutorotateToLandscapeRight: 1 + allowedAutorotateToLandscapeLeft: 1 + useOSAutorotation: 1 + use32BitDisplayBuffer: 1 + disableDepthAndStencilBuffers: 0 + defaultIsFullScreen: 1 + defaultIsNativeResolution: 1 + runInBackground: 0 + captureSingleScreen: 0 + Override IPod Music: 0 + Prepare IOS For Recording: 0 + submitAnalytics: 1 + usePlayerLog: 1 + bakeCollisionMeshes: 0 + forceSingleInstance: 0 + resizableWindow: 0 + useMacAppStoreValidation: 0 + gpuSkinning: 0 + xboxPIXTextureCapture: 0 + xboxEnableAvatar: 0 + xboxEnableKinect: 0 + xboxEnableKinectAutoTracking: 0 + xboxEnableFitness: 0 + visibleInBackground: 0 + macFullscreenMode: 2 + d3d9FullscreenMode: 1 + d3d11FullscreenMode: 1 + xboxSpeechDB: 0 + xboxEnableHeadOrientation: 0 + xboxEnableGuest: 0 + n3dsDisableStereoscopicView: 0 + n3dsEnableSharedListOpt: 1 + n3dsEnableVSync: 0 + xboxOneResolution: 0 + ps3SplashScreen: {fileID: 0} + videoMemoryForVertexBuffers: 0 + psp2PowerMode: 0 + psp2AcquireBGM: 1 + wiiUTVResolution: 0 + wiiUGamePadMSAA: 1 + wiiUSupportsNunchuk: 0 + wiiUSupportsClassicController: 0 + wiiUSupportsBalanceBoard: 0 + wiiUSupportsMotionPlus: 0 + wiiUSupportsProController: 0 + wiiUAllowScreenCapture: 1 + wiiUControllerCount: 0 + m_SupportedAspectRatios: + 4:3: 1 + 5:4: 1 + 16:10: 1 + 16:9: 1 + Others: 1 + bundleIdentifier: com.facebook.sdk.samples.rps + bundleVersion: 1.0 + preloadedAssets: [] + metroEnableIndependentInputSource: 0 + metroEnableLowLatencyPresentationAPI: 0 + xboxOneDisableKinectGpuReservation: 0 + virtualRealitySupported: 0 + productGUID: 4c7bd641802e04cafb43562bb7053c64 + AndroidBundleVersionCode: 1 + AndroidMinSdkVersion: 15 + AndroidPreferredInstallLocation: 1 + aotOptions: + apiCompatibilityLevel: 2 + stripEngineCode: 1 + iPhoneStrippingLevel: 0 + iPhoneScriptCallOptimization: 0 + iPhoneBuildNumber: 0 + ForceInternetPermission: 0 + ForceSDCardPermission: 0 + CreateWallpaper: 0 + APKExpansionFiles: 0 + preloadShaders: 0 + StripUnusedMeshComponents: 0 + VertexChannelCompressionMask: + serializedVersion: 2 + m_Bits: 238 + iPhoneSdkVersion: 988 + iPhoneTargetOSVersion: 22 + uIPrerenderedIcon: 0 + uIRequiresPersistentWiFi: 0 + uIStatusBarHidden: 1 + uIExitOnSuspend: 0 + uIStatusBarStyle: 0 + iPhoneSplashScreen: {fileID: 0} + iPhoneHighResSplashScreen: {fileID: 0} + iPhoneTallHighResSplashScreen: {fileID: 0} + iPhone47inSplashScreen: {fileID: 0} + iPhone55inPortraitSplashScreen: {fileID: 0} + iPhone55inLandscapeSplashScreen: {fileID: 0} + iPadPortraitSplashScreen: {fileID: 0} + iPadHighResPortraitSplashScreen: {fileID: 0} + iPadLandscapeSplashScreen: {fileID: 0} + iPadHighResLandscapeSplashScreen: {fileID: 0} + iOSLaunchScreenType: 0 + iOSLaunchScreenPortrait: {fileID: 0} + iOSLaunchScreenLandscape: {fileID: 0} + iOSLaunchScreenBackgroundColor: + serializedVersion: 2 + rgba: 0 + iOSLaunchScreenFillPct: 100 + iOSLaunchScreenSize: 100 + iOSLaunchScreenCustomXibPath: + AndroidTargetDevice: 0 + AndroidSplashScreenScale: 0 + androidSplashScreen: {fileID: 0} + AndroidKeystoreName: + AndroidKeyaliasName: + AndroidTVCompatibility: 1 + AndroidIsGame: 1 + androidEnableBanner: 1 + m_AndroidBanners: + - width: 320 + height: 180 + banner: {fileID: 0} + androidGamepadSupportLevel: 0 + resolutionDialogBanner: {fileID: 0} + m_BuildTargetIcons: + - m_BuildTarget: + m_Icons: + - m_Icon: {fileID: 0} + m_Size: 128 + m_BuildTargetBatching: [] + m_BuildTargetGraphicsAPIs: [] + webPlayerTemplate: APPLICATION:Default + m_TemplateCustomTags: {} + wiiUTitleID: 0005000011000000 + wiiUGroupID: 00010000 + wiiUCommonSaveSize: 4096 + wiiUAccountSaveSize: 2048 + wiiUOlvAccessKey: 0 + wiiUTinCode: 0 + wiiUJoinGameId: 0 + wiiUJoinGameModeMask: 0000000000000000 + wiiUCommonBossSize: 0 + wiiUAccountBossSize: 0 + wiiUAddOnUniqueIDs: [] + wiiUMainThreadStackSize: 3072 + wiiULoaderThreadStackSize: 1024 + wiiUSystemHeapSize: 128 + wiiUTVStartupScreen: {fileID: 0} + wiiUGamePadStartupScreen: {fileID: 0} + wiiUProfilerLibPath: + actionOnDotNetUnhandledException: 1 + enableInternalProfiler: 0 + logObjCUncaughtExceptions: 1 + enableCrashReportAPI: 0 + locationUsageDescription: + XboxTitleId: + XboxImageXexPath: + XboxSpaPath: + XboxGenerateSpa: 0 + XboxDeployKinectResources: 0 + XboxSplashScreen: {fileID: 0} + xboxEnableSpeech: 0 + xboxAdditionalTitleMemorySize: 0 + xboxDeployKinectHeadOrientation: 0 + xboxDeployKinectHeadPosition: 0 + ps3TitleConfigPath: + ps3DLCConfigPath: + ps3ThumbnailPath: + ps3BackgroundPath: + ps3SoundPath: + ps3NPAgeRating: 12 + ps3TrophyCommId: + ps3NpCommunicationPassphrase: + ps3TrophyPackagePath: + ps3BootCheckMaxSaveGameSizeKB: 128 + ps3TrophyCommSig: + ps3SaveGameSlots: 1 + ps3TrialMode: 0 + ps3VideoMemoryForAudio: 0 + ps3EnableVerboseMemoryStats: 0 + ps3UseSPUForUmbra: 0 + ps3EnableMoveSupport: 1 + ps3DisableDolbyEncoding: 0 + ps4NPAgeRating: 12 + ps4NPTitleSecret: + ps4NPTrophyPackPath: + ps4ParentalLevel: 1 + ps4ContentID: ED1633-NPXX51362_00-0000000000000000 + ps4Category: 0 + ps4MasterVersion: 01.00 + ps4AppVersion: 01.00 + ps4AppType: 0 + ps4ParamSfxPath: + ps4VideoOutPixelFormat: 0 + ps4VideoOutResolution: 4 + ps4PronunciationXMLPath: + ps4PronunciationSIGPath: + ps4BackgroundImagePath: + ps4StartupImagePath: + ps4SaveDataImagePath: + ps4SdkOverride: + ps4BGMPath: + ps4ShareFilePath: + ps4NPtitleDatPath: + ps4RemotePlayKeyAssignment: -1 + ps4RemotePlayKeyMappingDir: + ps4EnterButtonAssignment: 1 + ps4ApplicationParam1: 0 + ps4ApplicationParam2: 0 + ps4ApplicationParam3: 0 + ps4ApplicationParam4: 0 + ps4DownloadDataSize: 0 + ps4GarlicHeapSize: 2048 + ps4Passcode: 5PN2qmWqBlQ9wQj99nsQzldVI5ZuGXbE + ps4pnSessions: 1 + ps4pnPresence: 1 + ps4pnFriends: 1 + ps4pnGameCustomData: 1 + playerPrefsSupport: 0 + ps4ReprojectionSupport: 0 + ps4attribUserManagement: 0 + ps4attribMoveSupport: 0 + ps4attrib3DSupport: 0 + ps4attribShareSupport: 0 + monoEnv: + psp2Splashimage: {fileID: 0} + psp2NPTrophyPackPath: + psp2NPSupportGBMorGJP: 0 + psp2NPAgeRating: 12 + psp2NPTitleDatPath: + psp2NPCommsID: + psp2NPCommunicationsID: + psp2NPCommsPassphrase: + psp2NPCommsSig: + psp2ParamSfxPath: + psp2ManualPath: + psp2LiveAreaGatePath: + psp2LiveAreaBackroundPath: + psp2LiveAreaPath: + psp2LiveAreaTrialPath: + psp2PatchChangeInfoPath: + psp2PatchOriginalPackage: + psp2PackagePassword: WRK5RhRXdCdG5nG5azdNMK66MuCV6GXi + psp2KeystoneFile: + psp2MemoryExpansionMode: 0 + psp2DRMType: 0 + psp2StorageType: 0 + psp2MediaCapacity: 0 + psp2DLCConfigPath: + psp2ThumbnailPath: + psp2BackgroundPath: + psp2SoundPath: + psp2TrophyCommId: + psp2TrophyPackagePath: + psp2PackagedResourcesPath: + psp2SaveDataQuota: 10240 + psp2ParentalLevel: 1 + psp2ShortTitle: Not Set + psp2ContentID: IV0000-ABCD12345_00-0123456789ABCDEF + psp2Category: 0 + psp2MasterVersion: 01.00 + psp2AppVersion: 01.00 + psp2TVBootMode: 0 + psp2EnterButtonAssignment: 2 + psp2TVDisableEmu: 0 + psp2AllowTwitterDialog: 1 + psp2Upgradable: 0 + psp2HealthWarning: 0 + psp2UseLibLocation: 0 + psp2InfoBarOnStartup: 0 + psp2InfoBarColor: 0 + psmSplashimage: {fileID: 0} + spritePackerPolicy: + scriptingDefineSymbols: {} + metroPackageName: SDKPackage + metroPackageLogo: + metroPackageLogo140: + metroPackageLogo180: + metroPackageLogo240: + metroPackageVersion: + metroCertificatePath: + metroCertificatePassword: + metroCertificateSubject: + metroCertificateIssuer: + metroCertificateNotAfter: 0000000000000000 + metroApplicationDescription: SDKPackage + metroStoreTileLogo80: + metroStoreTileLogo: + metroStoreTileLogo140: + metroStoreTileLogo180: + metroStoreTileWideLogo80: + metroStoreTileWideLogo: + metroStoreTileWideLogo140: + metroStoreTileWideLogo180: + metroStoreTileSmallLogo80: + metroStoreTileSmallLogo: + metroStoreTileSmallLogo140: + metroStoreTileSmallLogo180: + metroStoreSmallTile80: + metroStoreSmallTile: + metroStoreSmallTile140: + metroStoreSmallTile180: + metroStoreLargeTile80: + metroStoreLargeTile: + metroStoreLargeTile140: + metroStoreLargeTile180: + metroStoreSplashScreenImage: + metroStoreSplashScreenImage140: + metroStoreSplashScreenImage180: + metroPhoneAppIcon: + metroPhoneAppIcon140: + metroPhoneAppIcon240: + metroPhoneSmallTile: + metroPhoneSmallTile140: + metroPhoneSmallTile240: + metroPhoneMediumTile: + metroPhoneMediumTile140: + metroPhoneMediumTile240: + metroPhoneWideTile: + metroPhoneWideTile140: + metroPhoneWideTile240: + metroPhoneSplashScreenImage: + metroPhoneSplashScreenImage140: + metroPhoneSplashScreenImage240: + metroTileShortName: + metroCommandLineArgsFile: + metroTileShowName: 0 + metroMediumTileShowName: 0 + metroLargeTileShowName: 0 + metroWideTileShowName: 0 + metroDefaultTileSize: 1 + metroTileForegroundText: 1 + metroTileBackgroundColor: {r: 0, g: 0, b: 0, a: 1} + metroSplashScreenBackgroundColor: {r: 0, g: 0, b: 0, a: 1} + metroSplashScreenUseBackgroundColor: 0 + platformCapabilities: {} + metroFTAName: + metroFTAFileTypes: [] + metroProtocolName: + metroCompilationOverrides: 1 + blackberryDeviceAddress: + blackberryDevicePassword: + blackberryTokenPath: + blackberryTokenExires: + blackberryTokenAuthor: + blackberryTokenAuthorId: + blackberryCskPassword: + blackberrySaveLogPath: + blackberrySharedPermissions: 0 + blackberryCameraPermissions: 0 + blackberryGPSPermissions: 0 + blackberryDeviceIDPermissions: 0 + blackberryMicrophonePermissions: 0 + blackberryGamepadSupport: 0 + blackberryBuildId: 0 + blackberryLandscapeSplashScreen: {fileID: 0} + blackberryPortraitSplashScreen: {fileID: 0} + blackberrySquareSplashScreen: {fileID: 0} + tizenProductDescription: + tizenProductURL: + tizenSigningProfileName: + tizenGPSPermissions: 0 + tizenMicrophonePermissions: 0 + n3dsUseExtSaveData: 0 + n3dsCompressStaticMem: 1 + n3dsExtSaveDataNumber: 0x12345 + n3dsStackSize: 131072 + n3dsTargetPlatform: 2 + n3dsRegion: 7 + n3dsMediaSize: 0 + n3dsLogoStyle: 3 + n3dsTitle: GameName + n3dsProductCode: + n3dsApplicationId: 0xFF3FF + stvDeviceAddress: + stvProductDescription: + stvProductAuthor: + stvProductAuthorEmail: + stvProductLink: + stvProductCategory: 0 + XboxOneProductId: + XboxOneUpdateKey: + XboxOneSandboxId: + XboxOneContentId: + XboxOneTitleId: + XboxOneSCId: + XboxOneGameOsOverridePath: + XboxOnePackagingOverridePath: + XboxOneAppManifestOverridePath: + XboxOnePackageEncryption: 0 + XboxOnePackageUpdateGranularity: 2 + XboxOneDescription: + XboxOneIsContentPackage: 0 + XboxOneEnableGPUVariability: 0 + XboxOneSockets: {} + XboxOneSplashScreen: {fileID: 0} + XboxOneAllowedProductIds: [] + XboxOnePersistentLocalStorageSize: 0 + intPropertyNames: + - Android::ScriptingBackend + - Standalone::ScriptingBackend + - WebGL::ScriptingBackend + - WebGL::audioCompressionFormat + - WebGL::exceptionSupport + - WebGL::memorySize + - iOS::Architecture + - iOS::ScriptingBackend + Android::ScriptingBackend: 0 + Standalone::ScriptingBackend: 0 + WebGL::ScriptingBackend: 1 + WebGL::audioCompressionFormat: 4 + WebGL::exceptionSupport: 0 + WebGL::memorySize: 256 + iOS::Architecture: 0 + iOS::ScriptingBackend: 0 + boolPropertyNames: + - WebGL::analyzeBuildSize + - WebGL::dataCaching + - WebGL::useEmbeddedResources + - XboxOne::enus + WebGL::analyzeBuildSize: 0 + WebGL::dataCaching: 0 + WebGL::useEmbeddedResources: 0 + XboxOne::enus: 1 + stringPropertyNames: + - WebGL::emscriptenArgs + - WebGL::template + - additionalIl2CppArgs::additionalIl2CppArgs + WebGL::emscriptenArgs: + WebGL::template: APPLICATION:Default + additionalIl2CppArgs::additionalIl2CppArgs: + firstStreamedSceneWithResources: 0 + cloudProjectId: + projectName: + organizationId: + cloudEnabled: 0 diff --git a/Facebook.Unity/ProjectSettings/QualitySettings.asset b/Facebook.Unity/ProjectSettings/QualitySettings.asset new file mode 100644 index 000000000..856ed7a73 --- /dev/null +++ b/Facebook.Unity/ProjectSettings/QualitySettings.asset @@ -0,0 +1,147 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!47 &1 +QualitySettings: + m_ObjectHideFlags: 0 + serializedVersion: 5 + m_CurrentQuality: 5 + m_QualitySettings: + - serializedVersion: 2 + name: Fastest + pixelLightCount: 0 + shadows: 0 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 15 + shadowCascade2Split: .333333343 + shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} + blendWeights: 1 + textureQuality: 1 + anisotropicTextures: 0 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 0 + lodBias: .300000012 + maximumLODLevel: 0 + particleRaycastBudget: 4 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Fast + pixelLightCount: 0 + shadows: 0 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 20 + shadowCascade2Split: .333333343 + shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 0 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 0 + lodBias: .400000006 + maximumLODLevel: 0 + particleRaycastBudget: 16 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Simple + pixelLightCount: 1 + shadows: 1 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 20 + shadowCascade2Split: .333333343 + shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 1 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 0 + lodBias: .699999988 + maximumLODLevel: 0 + particleRaycastBudget: 64 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Good + pixelLightCount: 2 + shadows: 2 + shadowResolution: 1 + shadowProjection: 1 + shadowCascades: 2 + shadowDistance: 40 + shadowCascade2Split: .333333343 + shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 1 + antiAliasing: 0 + softParticles: 0 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 1 + maximumLODLevel: 0 + particleRaycastBudget: 256 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Beautiful + pixelLightCount: 3 + shadows: 2 + shadowResolution: 2 + shadowProjection: 1 + shadowCascades: 2 + shadowDistance: 70 + shadowCascade2Split: .333333343 + shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} + blendWeights: 4 + textureQuality: 0 + anisotropicTextures: 2 + antiAliasing: 2 + softParticles: 1 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 1.5 + maximumLODLevel: 0 + particleRaycastBudget: 1024 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Fantastic + pixelLightCount: 4 + shadows: 2 + shadowResolution: 2 + shadowProjection: 1 + shadowCascades: 4 + shadowDistance: 150 + shadowCascade2Split: .333333343 + shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} + blendWeights: 4 + textureQuality: 0 + anisotropicTextures: 2 + antiAliasing: 2 + softParticles: 1 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 2 + maximumLODLevel: 0 + particleRaycastBudget: 4096 + excludedTargetPlatforms: [] + m_PerPlatformDefaultQuality: {} diff --git a/Facebook.Unity/ProjectSettings/TagManager.asset b/Facebook.Unity/ProjectSettings/TagManager.asset new file mode 100644 index 000000000..ac1fdfebf --- /dev/null +++ b/Facebook.Unity/ProjectSettings/TagManager.asset @@ -0,0 +1,38 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!78 &1 +TagManager: + tags: + - + Builtin Layer 0: Default + Builtin Layer 1: TransparentFX + Builtin Layer 2: Ignore Raycast + Builtin Layer 3: + Builtin Layer 4: Water + Builtin Layer 5: + Builtin Layer 6: + Builtin Layer 7: + User Layer 8: + User Layer 9: + User Layer 10: + User Layer 11: + User Layer 12: + User Layer 13: + User Layer 14: + User Layer 15: + User Layer 16: + User Layer 17: + User Layer 18: + User Layer 19: + User Layer 20: + User Layer 21: + User Layer 22: + User Layer 23: + User Layer 24: + User Layer 25: + User Layer 26: + User Layer 27: + User Layer 28: + User Layer 29: + User Layer 30: + User Layer 31: diff --git a/Facebook.Unity/ProjectSettings/TimeManager.asset b/Facebook.Unity/ProjectSettings/TimeManager.asset new file mode 100644 index 000000000..f0e494b67 --- /dev/null +++ b/Facebook.Unity/ProjectSettings/TimeManager.asset @@ -0,0 +1,8 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!5 &1 +TimeManager: + m_ObjectHideFlags: 0 + Fixed Timestep: .0199999996 + Maximum Allowed Timestep: .333333343 + m_TimeScale: 1 diff --git a/Facebook.Unity/ProjectSettings/UnityAdsSettings.asset b/Facebook.Unity/ProjectSettings/UnityAdsSettings.asset new file mode 100644 index 000000000..224050ce8 --- /dev/null +++ b/Facebook.Unity/ProjectSettings/UnityAdsSettings.asset @@ -0,0 +1,11 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!292 &1 +UnityAdsSettings: + m_ObjectHideFlags: 0 + m_Enabled: 0 + m_InitializeOnStartup: 1 + m_TestMode: 0 + m_EnabledPlatforms: 4294967295 + m_IosGameId: + m_AndroidGameId: diff --git a/Facebook.Unity/ProjectSettings/UnityAnalyticsManager.asset b/Facebook.Unity/ProjectSettings/UnityAnalyticsManager.asset new file mode 100644 index 000000000..4a7b66883 --- /dev/null +++ b/Facebook.Unity/ProjectSettings/UnityAnalyticsManager.asset @@ -0,0 +1,10 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!303 &1 +UnityAnalyticsManager: + m_ObjectHideFlags: 0 + m_Enabled: 0 + m_InitializeOnStartup: 1 + m_TestMode: 0 + m_TestEventUrl: + m_TestConfigUrl: diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 000000000..bdb9fc54b --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,17 @@ +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. diff --git a/README.mdown b/README.mdown new file mode 100644 index 000000000..148940a94 --- /dev/null +++ b/README.mdown @@ -0,0 +1,50 @@ +Facebook SDK for Unity +======================== + +This open-source library allows you to integrate Facebook into your Unity app. + +Learn more about about the provided samples, documentation, integrating the SDK into your app, accessing source code, and more at https://developers.facebook.com/docs/unity + +TRY IT OUT +---------- +1. Check-out the tutorials available online at https://developers.facebook.com/docs/unity/getting-started +2. Start coding! Visit https://developers.facebook.com/docs/unity/ for tutorials and reference documentation. + +FEATURES +-------- +* Login - https://developers.facebook.com/docs/facebook-login +* Sharing - https://developers.facebook.com/docs/sharing +* App Links - https://developers.facebook.com/docs/applinks +* Graph API - https://developers.facebook.com/docs/graph-api +* Analytics for Apps - https://developers.facebook.com/docs/analytics + +GIVE FEEDBACK +------------- +Please report bugs or issues to https://developers.facebook.com/bugs/ + +You can also join the Facebook Developers Group on Facebook (https://www.facebook.com/groups/fbdevelopers/) or ask questions on Stack Overflow (http://facebook.stackoverflow.com) + +CONTRIBUTING +------------- +We are able to accept contributions to the Facebook SDK for Unity. To contribute please do the following. +- Follow the instructions in the [CONTRIBUTING.mdown](https://github.com/facebook/facebook-sdk-for-unity/blob/master/CONTRIBUTING.mdown). +- Submit your pull request to the [dev](https://github.com/facebook/facebook-sdk-for-unity/tree/dev) branch. This allows us to merge your change into our internal master and then push out the change in the next release. + +LICENSE +------- +Except as otherwise noted, the Facebook SDK for Unity is licensed under the Facebook Platform License (https://github.com/facebook/facebook-sdk-for-unity/blob/master/LICENSE.txt). + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + +DEVELOPER TERMS +--------------- + +- By enabling Facebook integrations, including through this SDK, you can share information with Facebook, including information about people’s use of your app. Facebook will use information received in accordance with our Data Use Policy (https://www.facebook.com/about/privacy/), including to provide you with insights about the effectiveness of your ads and the use of your app. These integrations also enable us and our partners to serve ads on and off Facebook. + +- You may limit your sharing of information with us by updating the Insights control in the developer tool (https://developers.facebook.com/apps/[app_id]/settings/advanced). + +- If you use a Facebook integration, including to share information with us, you agree and confirm that you have provided appropriate and sufficiently prominent notice to and obtained the appropriate consent from your users regarding such collection, use, and disclosure (including, at a minimum, through your privacy policy). You further agree that you will not share information with us about children under the age of 13. + +- You agree to comply with all applicable laws and regulations and also agree to our Terms (https://www.facebook.com/policies/), including our Platform Policies (https://developers.facebook.com/policy/) and Advertising Guidelines, as applicable (https://www.facebook.com/ad_guidelines.php). + +By using the Facebook SDK for Unity you agree to these terms. diff --git a/facebook-android-wrapper/AndroidManifest.xml b/facebook-android-wrapper/AndroidManifest.xml new file mode 100644 index 000000000..1c455ec92 --- /dev/null +++ b/facebook-android-wrapper/AndroidManifest.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/facebook-android-wrapper/build.gradle b/facebook-android-wrapper/build.gradle new file mode 100644 index 000000000..08c5149d6 --- /dev/null +++ b/facebook-android-wrapper/build.gradle @@ -0,0 +1,69 @@ +apply plugin: 'com.android.library' + +allprojects { + gradle.projectsEvaluated { + tasks.withType(JavaCompile) { + options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" + } + } +} + +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.3.0' + } +} + +def fbSdkVersion = project.hasProperty("sdkVersion") ? sdkVersion : '4.6.0' + +repositories { + // If we are doing a local build use our local dir + if (project.hasProperty("localRepo")) { + flatDir { + dirs localRepo + } + } else { + mavenCentral() + } +} + +dependencies { + // Use local file instead of maven to enable testing with versions + // not released to maven. + if (project.hasProperty("localRepo")) { + compile 'com.facebook.android:facebook-android-sdk:' + fbSdkVersion + '@aar' + compile fileTree(dir: 'libs', include: ['*.jar']) + } else { + compile 'com.facebook.android:facebook-android-sdk:' + fbSdkVersion + } +} + +android { + compileSdkVersion 23 + buildToolsVersion '23.0.1' + + defaultConfig { + minSdkVersion 15 + targetSdkVersion 23 + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + } + + sourceSets { + main { + manifest.srcFile 'AndroidManifest.xml' + java.srcDirs = ['src'] + resources.srcDirs = ['src'] + aidl.srcDirs = ['src'] + renderscript.srcDirs = ['src'] + res.srcDirs = ['res'] + assets.srcDirs = ['assets'] + } + } +} diff --git a/facebook-android-wrapper/gradle.properties b/facebook-android-wrapper/gradle.properties new file mode 100644 index 000000000..89e0d99e2 --- /dev/null +++ b/facebook-android-wrapper/gradle.properties @@ -0,0 +1,18 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# Default value: -Xmx10248m -XX:MaxPermSize=256m +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true diff --git a/facebook-android-wrapper/gradle/wrapper/gradle-wrapper.jar b/facebook-android-wrapper/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..b5166dad4d90021f6a0b45268c0755719f1d5cd4 GIT binary patch literal 52266 zcmagFbCf4Rwk}$>ZR1zAZQJOwZQHhO+paF#?6Pg6tNQl2Gw+-`^X9&nYei=Mv13KV zUK`&=D9V6>!2kh4K>-;km5KxXeL()}_4k4PJLJSvh3KT@#Th_>6#s?LiDq?Q;4gvd z-+}gj63Pk5ONooAsM5=cKgvx{$;!~tFTl&tQO{1#H7heNv+Nx|Ow)}^&B)ErNYMhr zT!fjV9hGQPbzqX09hDf354Pf*XWlv8I|2V63;y`Goq_#b(B8@XUpDpcG_e1qF?TXF zu`&JsBt`vKQg>DEo zGsuV(x@*CvP2OwTK1BVq$BB~{g%4U4!}IE?0a$$P>_Fzr+SdI(J< zGWZkANZ6;1BYn!ZlH9PXwRS-r?NWLR+^~(Mv#pQy0+3xzheZ(*>Ka8u2}9?3Df&ZZ z%-_E{21wY6QM@Y_V@F0ok_TsP5a8FP%4`qyD3IWSjl}0uP8c#z0w*kv1w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per/gradle-wrapper.properties new file mode 100644 index 000000000..40451d683 --- /dev/null +++ b/facebook-android-wrapper/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon May 18 10:48:51 PDT 2015 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.6-all.zip diff --git a/facebook-android-wrapper/gradlew b/facebook-android-wrapper/gradlew new file mode 100755 index 000000000..91a7e269e --- /dev/null +++ b/facebook-android-wrapper/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/facebook-android-wrapper/gradlew.bat b/facebook-android-wrapper/gradlew.bat new file mode 100644 index 000000000..aec99730b --- /dev/null +++ b/facebook-android-wrapper/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/facebook-android-wrapper/proguard-project.txt b/facebook-android-wrapper/proguard-project.txt new file mode 100644 index 000000000..f2fe1559a --- /dev/null +++ b/facebook-android-wrapper/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/facebook-android-wrapper/project.properties b/facebook-android-wrapper/project.properties new file mode 100644 index 000000000..395ccb600 --- /dev/null +++ b/facebook-android-wrapper/project.properties @@ -0,0 +1,13 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +android.library=true diff --git a/facebook-android-wrapper/src/com/facebook/unity/AppInviteDialogActivity.java b/facebook-android-wrapper/src/com/facebook/unity/AppInviteDialogActivity.java new file mode 100644 index 000000000..e24788f83 --- /dev/null +++ b/facebook-android-wrapper/src/com/facebook/unity/AppInviteDialogActivity.java @@ -0,0 +1,74 @@ +/** + * 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. + */ + +package com.facebook.unity; + +import android.os.Bundle; + +import com.facebook.FacebookCallback; +import com.facebook.FacebookException; +import com.facebook.share.model.AppInviteContent; +import com.facebook.share.widget.AppInviteDialog; + +public class AppInviteDialogActivity extends BaseActivity { + public static final String DIALOG_PARAMS = "dialog_params"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + final UnityMessage response = new UnityMessage("OnAppInviteComplete"); + Bundle params = getIntent().getBundleExtra(DIALOG_PARAMS); + + AppInviteContent.Builder contentBuilder = new AppInviteContent.Builder(); + if (params.containsKey(Constants.CALLBACK_ID_KEY)) { + response.put(Constants.CALLBACK_ID_KEY, params.getString(Constants.CALLBACK_ID_KEY)); + } + + if (params.containsKey("appLinkUrl")) { + contentBuilder.setApplinkUrl(params.getString("appLinkUrl")); + } + + if (params.containsKey("previewImageUrl")) { + contentBuilder.setPreviewImageUrl(params.getString("previewImageUrl")); + } + + AppInviteDialog dialog = new AppInviteDialog(this); + dialog.registerCallback(this.mCallbackManager, new FacebookCallback() { + @Override + public void onSuccess(AppInviteDialog.Result result) { + response.put("didComplete", true); + response.send(); + } + + @Override + public void onCancel() { + response.putCancelled(); + response.send(); + } + + @Override + public void onError(FacebookException e) { + response.sendError(e.getMessage()); + } + }); + dialog.show(contentBuilder.build()); + } +} diff --git a/facebook-android-wrapper/src/com/facebook/unity/BaseActivity.java b/facebook-android-wrapper/src/com/facebook/unity/BaseActivity.java new file mode 100644 index 000000000..4c0cbefc5 --- /dev/null +++ b/facebook-android-wrapper/src/com/facebook/unity/BaseActivity.java @@ -0,0 +1,45 @@ +/** + * 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. + */ + +package com.facebook.unity; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; + +import com.facebook.CallbackManager; + +public abstract class BaseActivity extends Activity { + public static final String ACTIVITY_PARAMS = "activity_params"; + protected CallbackManager mCallbackManager; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + mCallbackManager = CallbackManager.Factory.create(); + } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + mCallbackManager.onActivityResult(requestCode, resultCode, data); + finish(); + } +} diff --git a/facebook-android-wrapper/src/com/facebook/unity/Constants.java b/facebook-android-wrapper/src/com/facebook/unity/Constants.java new file mode 100644 index 000000000..70dbaa052 --- /dev/null +++ b/facebook-android-wrapper/src/com/facebook/unity/Constants.java @@ -0,0 +1,25 @@ +/** + * 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. + */ + +package com.facebook.unity; + +public class Constants { + public static final String CALLBACK_ID_KEY = "callback_id"; +} diff --git a/facebook-android-wrapper/src/com/facebook/unity/FB.java b/facebook-android-wrapper/src/com/facebook/unity/FB.java new file mode 100644 index 000000000..85100162b --- /dev/null +++ b/facebook-android-wrapper/src/com/facebook/unity/FB.java @@ -0,0 +1,385 @@ +/** + * 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. + */ + +package com.facebook.unity; + +import java.math.BigDecimal; +import java.util.*; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +import android.annotation.TargetApi; +import android.content.Intent; +import android.app.Activity; +import android.os.Build; +import android.os.Bundle; +import android.util.Log; +import android.util.Base64; +import android.content.pm.*; +import android.content.pm.PackageManager.NameNotFoundException; + +import com.facebook.*; +import com.facebook.appevents.AppEventsLogger; +import com.facebook.applinks.AppLinkData; +import com.facebook.internal.BundleJSONConverter; +import com.facebook.internal.Utility; +import com.facebook.internal.InternalSettings; +import com.facebook.login.LoginManager; +import com.facebook.share.widget.ShareDialog; + +import org.json.JSONException; + +public class FB { + static final String TAG = FB.class.getName(); + // i.e. the game object that receives this message + static final String FB_UNITY_OBJECT = "UnityFacebookSDKPlugin"; + private static Intent intent; + private static AppEventsLogger appEventsLogger; + static ShareDialog.Mode ShareDialogMode = ShareDialog.Mode.AUTOMATIC; + + private static AppEventsLogger getAppEventsLogger() { + if (appEventsLogger == null) { + appEventsLogger = AppEventsLogger.newLogger(getUnityActivity().getApplicationContext()); + } + return appEventsLogger; + } + + public static Activity getUnityActivity() { + return UnityReflection.GetUnityActivity(); + } + + @UnityCallable + public static void Init(String params_str) { + Log.v(TAG, "Init(" + params_str + ")"); + UnityParams unity_params = UnityParams.parse(params_str, "couldn't parse init params: "+params_str); + String appID; + if (unity_params.hasString("appId")) { + appID = unity_params.getString("appId"); + } else { + appID = Utility.getMetadataApplicationId(getUnityActivity()); + } + + FacebookSdk.setApplicationId(appID); + FacebookSdk.sdkInitialize(FB.getUnityActivity(), new FacebookSdk.InitializeCallback() { + @Override + public void onInitialized() { + // If we have a cached access token send it back as well + if (AccessToken.getCurrentAccessToken() != null) { + FBLogin.sendLoginSuccessMessage(AccessToken.getCurrentAccessToken(), null); + } + } + }); + final UnityMessage unityMessage = new UnityMessage("OnInitComplete"); + unityMessage.put("key_hash", FB.getKeyHash()); + unityMessage.send(); + } + + @UnityCallable + public static void LoginWithReadPermissions(String params_str) { + Log.v(TAG, "LoginWithReadPermissions(" + params_str + ")"); + Intent intent = new Intent(getUnityActivity(), FBUnityLoginActivity.class); + intent.putExtra(FBUnityLoginActivity.LOGIN_PARAMS, params_str); + intent.putExtra(FBUnityLoginActivity.LOGIN_TYPE, FBUnityLoginActivity.LoginType.READ); + getUnityActivity().startActivity(intent); + } + + @UnityCallable + public static void LoginWithPublishPermissions(String params_str) { + Log.v(TAG, "LoginWithPublishPermissions(" + params_str + ")"); + Intent intent = new Intent(getUnityActivity(), FBUnityLoginActivity.class); + intent.putExtra(FBUnityLoginActivity.LOGIN_PARAMS, params_str); + intent.putExtra(FBUnityLoginActivity.LOGIN_TYPE, FBUnityLoginActivity.LoginType.PUBLISH); + getUnityActivity().startActivity(intent); + } + + @UnityCallable + public static void Logout(String params_str) { + Log.v(TAG, "Logout(" + params_str + ")"); + LoginManager.getInstance().logOut(); + UnityMessage message = new UnityMessage("OnLogoutComplete"); + message.put("did_complete", true); + message.send(); + } + + @UnityCallable + public static void AppRequest(String params_str) { + Log.v(TAG, "AppRequest(" + params_str + ")"); + Intent intent = new Intent(getUnityActivity(), FBUnityGameRequestActivity.class); + UnityParams unity_params = UnityParams.parse(params_str); + Bundle params = unity_params.getStringParams(); + intent.putExtra(FBUnityGameRequestActivity.GAME_REQUEST_PARAMS, params); + getUnityActivity().startActivity(intent); + } + + @UnityCallable + public static void GameGroupCreate(String params_str) { + Log.v(TAG, "GameGroupCreate(" + params_str + ")"); + final UnityParams unity_params = UnityParams.parse(params_str); + final Bundle params = unity_params.getStringParams(); + Intent intent = new Intent(getUnityActivity(), FBUnityCreateGameGroupActivity.class); + intent.putExtra(FBUnityCreateGameGroupActivity.CREATE_GAME_GROUP_PARAMS, params); + getUnityActivity().startActivity(intent); + } + + @UnityCallable + public static void GameGroupJoin(String params_str) { + Log.v(TAG, "GameGroupJoin(" + params_str + ")"); + final UnityParams unity_params = UnityParams.parse(params_str); + final Bundle params = unity_params.getStringParams(); + Intent intent = new Intent(getUnityActivity(), FBUnityJoinGameGroupActivity.class); + intent.putExtra(FBUnityJoinGameGroupActivity.JOIN_GAME_GROUP_PARAMS, params); + getUnityActivity().startActivity(intent); + } + + @UnityCallable + public static void ShareLink(String params_str) { + Log.v(TAG, "ShareLink(" + params_str + ")"); + final UnityParams unity_params = UnityParams.parse(params_str); + final Bundle params = unity_params.getStringParams(); + Intent intent = new Intent(getUnityActivity(), FBUnityDialogsActivity.class); + intent.putExtra(FBUnityDialogsActivity.DIALOG_TYPE, ShareDialogMode); + intent.putExtra(FBUnityDialogsActivity.SHARE_DIALOG_PARAMS, params); + getUnityActivity().startActivity(intent); + } + + @UnityCallable + public static void FeedShare(String params_str) { + Log.v(TAG, "FeedShare(" + params_str + ")"); + final UnityParams unityParams = UnityParams.parse(params_str); + final Bundle params = unityParams.getStringParams(); + Intent intent = new Intent(getUnityActivity(), FBUnityDialogsActivity.class); + intent.putExtra(FBUnityDialogsActivity.DIALOG_TYPE, ShareDialog.Mode.FEED); + intent.putExtra(FBUnityDialogsActivity.FEED_DIALOG_PARAMS, params); + getUnityActivity().startActivity(intent); + } + + @UnityCallable + public static void PublishInstall(String params_str) { + Log.v(TAG, "PublishInstall(" + params_str + ")"); + final UnityMessage unityMessage = new UnityMessage("OnPublishInstallComplete"); + final UnityParams unity_params = UnityParams.parse(params_str); + if (unity_params.hasString(Constants.CALLBACK_ID_KEY)) { + unityMessage.put( + Constants.CALLBACK_ID_KEY, + unity_params.getString(Constants.CALLBACK_ID_KEY)); + } + AppEventsLogger.activateApp(getUnityActivity().getApplicationContext()); + unityMessage.send(); + } + + @UnityCallable + public static void ActivateApp(String params_str) { + Log.v(TAG, "ActivateApp(" + params_str + ")"); + final UnityParams unity_params = UnityParams.parse(params_str); + if (unity_params.hasString("app_id")) { + AppEventsLogger.activateApp( + getUnityActivity().getApplicationContext(), + unity_params.getString("app_id")); + } else { + AppEventsLogger.activateApp(getUnityActivity().getApplicationContext()); + } + } + + public static void SetIntent(Intent intent) { + FB.intent = intent; + } + + public static void SetLimitEventUsage(String params_str) { + Log.v(TAG, "SetLimitEventUsage(" + params_str + ")"); + FacebookSdk.setLimitEventAndDataUsage( + getUnityActivity().getApplicationContext(), + Boolean.valueOf(params_str)); + } + + @UnityCallable + public static void AppEvents(String params_str) { + Log.v(TAG, "AppEvents(" + params_str + ")"); + UnityParams unity_params = UnityParams.parse(params_str); + + Bundle parameters = new Bundle(); + if (unity_params.has("parameters")) { + UnityParams unity_params_parameter = unity_params.getParamsObject("parameters"); + parameters = unity_params_parameter.getStringParams(); + } + + if (unity_params.has("logPurchase")) { + FB.getAppEventsLogger().logPurchase( + new BigDecimal(unity_params.getDouble("logPurchase")), + Currency.getInstance(unity_params.getString("currency")), + parameters + ); + } else if (unity_params.hasString("logEvent")) { + if (unity_params.has("valueToSum")) { + FB.getAppEventsLogger().logEvent( + unity_params.getString("logEvent"), + unity_params.getDouble("valueToSum"), + parameters + ); + } else { + FB.getAppEventsLogger().logEvent( + unity_params.getString("logEvent"), + parameters + ); + } + } else { + Log.e(TAG, "couldn't logPurchase or logEvent params: " + params_str); + } + } + + @UnityCallable + public static void SetShareDialogMode(String mode) { + Log.v(TAG, "SetShareDialogMode(" + mode + ")"); + if (mode.equalsIgnoreCase("NATIVE")) { + ShareDialogMode = ShareDialog.Mode.NATIVE; + } else if (mode.equalsIgnoreCase("WEB")) { + ShareDialogMode = ShareDialog.Mode.WEB; + } else if (mode.equalsIgnoreCase(("FEED"))) { + ShareDialogMode = ShareDialog.Mode.FEED; + } else { + ShareDialogMode = ShareDialog.Mode.AUTOMATIC; + } + } + + @UnityCallable + public static String GetSdkVersion() { + return FacebookSdk.getSdkVersion(); + } + + @UnityCallable + public static void SetUserAgentSuffix(String suffix) { + Log.v(TAG, "SetUserAgentSuffix(" + suffix + ")"); + InternalSettings.setCustomUserAgent(suffix); + } + + @UnityCallable + public static void AppInvite(String paramsStr) { + Log.v(TAG, "AppInvite(" + paramsStr + ")"); + Intent intent = new Intent(getUnityActivity(), AppInviteDialogActivity.class); + UnityParams unityParams = UnityParams.parse(paramsStr); + Bundle params = unityParams.getStringParams(); + intent.putExtra(AppInviteDialogActivity.DIALOG_PARAMS, params); + getUnityActivity().startActivity(intent); + } + + @UnityCallable + public static void FetchDeferredAppLinkData(String paramsStr) { + FB.LogMethodCall("FetchDeferredAppLinkData", paramsStr); + + UnityParams unityParams = UnityParams.parse(paramsStr); + final UnityMessage unityMessage = new UnityMessage("OnFetchDeferredAppLinkComplete"); + if (unityParams.hasString("callback_id")) { + unityMessage.put("callback_id", unityParams.getString("callback_id")); + } + + AppLinkData.fetchDeferredAppLinkData( + getUnityActivity(), + new AppLinkData.CompletionHandler() { + @Override + public void onDeferredAppLinkDataFetched(AppLinkData appLinkData) { + FB.addAppLinkToMessage(unityMessage, appLinkData); + unityMessage.send(); + } + }); + } + + @UnityCallable + public static void GetAppLink(String paramsStr) { + Log.v(TAG, "GetAppLink(" + paramsStr + ")"); + final UnityParams unityParams = UnityParams.parse(paramsStr); + UnityMessage unityMessage = UnityMessage.createWithCallbackFromParams( + "OnGetAppLinkComplete", + unityParams); + + // If we don't have an intent return + if (intent == null) + { + unityMessage.put("did_complete", true); + unityMessage.send(); + return; + } + + // Check to see if we have any app link data on the intent + AppLinkData appLinkData = AppLinkData.createFromAlApplinkData(intent); + if (appLinkData != null) { + // We have an app link + FB.addAppLinkToMessage(unityMessage, appLinkData); + } else if (intent.getData() != null) { + // We have a deep link + unityMessage.put("url", intent.getDataString()); + } else { + // No deep link or app link was provided when activity was started + unityMessage.put("did_complete", true); + } + + unityMessage.send(); + } + + /** + * Provides the key hash to solve the openSSL issue with Amazon + * @return key hash + */ + @TargetApi(Build.VERSION_CODES.FROYO) + public static String getKeyHash() { + try { + PackageInfo info = getUnityActivity().getPackageManager().getPackageInfo( + getUnityActivity().getPackageName(), PackageManager.GET_SIGNATURES); + for (Signature signature : info.signatures){ + MessageDigest md = MessageDigest.getInstance("SHA"); + md.update(signature.toByteArray()); + String keyHash = Base64.encodeToString(md.digest(), Base64.DEFAULT); + Log.d(TAG, "KeyHash: " + keyHash); + return keyHash; + } + } catch (NameNotFoundException e) { + } catch (NoSuchAlgorithmException e) { + } + return ""; + } + + private static void startActivity(Class cls, String paramsStr) { + Intent intent = new Intent(getUnityActivity(), cls); + UnityParams unityParams = UnityParams.parse(paramsStr); + Bundle params = unityParams.getStringParams(); + intent.putExtra(BaseActivity.ACTIVITY_PARAMS, params); + getUnityActivity().startActivity(intent); + } + + private static void LogMethodCall(String methodName, String paramsStr) { + Log.v(TAG, String.format(Locale.ROOT, "%s(%s)", methodName, paramsStr)); + } + + private static void addAppLinkToMessage(UnityMessage unityMessage, AppLinkData appLinkData) { + if (appLinkData == null) { + unityMessage.put("did_complete", true); + return; + } + + unityMessage.put("ref", appLinkData.getRef()); + unityMessage.put("target_url", appLinkData.getTargetUri().toString()); + try { + if (appLinkData.getArgumentBundle() != null) { + unityMessage.put("extras", BundleJSONConverter.convertToJSON( + appLinkData.getArgumentBundle()).toString()); + } + } catch (JSONException ex) { + Log.e(TAG, ex.getLocalizedMessage()); + } + } +} diff --git a/facebook-android-wrapper/src/com/facebook/unity/FBDialogUtils.java b/facebook-android-wrapper/src/com/facebook/unity/FBDialogUtils.java new file mode 100644 index 000000000..46c206f0f --- /dev/null +++ b/facebook-android-wrapper/src/com/facebook/unity/FBDialogUtils.java @@ -0,0 +1,101 @@ +/** + * 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. + */ + +package com.facebook.unity; + +import com.facebook.share.internal.ShareFeedContent; +import com.facebook.share.model.ShareLinkContent; +import com.facebook.share.widget.ShareDialog; + +import android.net.Uri; +import android.os.Bundle; + +class FBDialogUtils { + public static ShareLinkContent.Builder createShareContentBuilder(Bundle params) { + ShareLinkContent.Builder builder = new ShareLinkContent.Builder(); + + if (params.containsKey("content_title")) { + builder.setContentTitle(params.getString("content_title")); + } + + if (params.containsKey("content_description")) { + builder.setContentDescription(params.getString("content_description")); + } + + if (params.containsKey("content_url")) { + builder.setContentUrl(Uri.parse(params.getString("content_url"))); + } + + if (params.containsKey("photo_url")) { + builder.setImageUrl(Uri.parse(params.getString("photo_url"))); + } + + return builder; + } + + public static ShareFeedContent.Builder createFeedContentBuilder(Bundle params) { + ShareFeedContent.Builder builder = new ShareFeedContent.Builder(); + + if (params.containsKey("toId")) { + builder.setToId(params.getString("toId")); + } + + if (params.containsKey("link")) { + builder.setLink(params.getString("link")); + } + + if (params.containsKey("linkName")) { + builder.setLinkName(params.getString("linkName")); + } + + if (params.containsKey("linkCaption")) { + builder.setLinkCaption(params.getString("linkCaption")); + } + + if (params.containsKey("linkDescription")) { + builder.setLinkDescription(params.getString("linkDescription")); + } + + if (params.containsKey("picture")) { + builder.setPicture(params.getString("picture")); + } + + if (params.containsKey("mediaSource")) { + builder.setMediaSource(params.getString("mediaSource")); + } + + return builder; + } + + public static ShareDialog.Mode intToMode(int mode) { + switch (mode) { + case 0: + return ShareDialog.Mode.AUTOMATIC; + case 1: + return ShareDialog.Mode.NATIVE; + case 2: + return ShareDialog.Mode.WEB; + case 3: + return ShareDialog.Mode.FEED; + default: + return null; + } + } +} diff --git a/facebook-android-wrapper/src/com/facebook/unity/FBLogin.java b/facebook-android-wrapper/src/com/facebook/unity/FBLogin.java new file mode 100644 index 000000000..8c308f24e --- /dev/null +++ b/facebook-android-wrapper/src/com/facebook/unity/FBLogin.java @@ -0,0 +1,126 @@ +/** + * 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. + */ + +package com.facebook.unity; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import android.text.TextUtils; +import android.util.Log; + +import com.facebook.AccessToken; +import com.facebook.FacebookCallback; +import com.facebook.FacebookException; +import com.facebook.FacebookSdk; +import com.facebook.login.LoginBehavior; +import com.facebook.login.LoginManager; +import com.facebook.login.LoginResult; + +public class FBLogin { + public static void loginWithReadPermissions( + String params, + final FBUnityLoginActivity activity) { + login(params, activity, false); + } + + public static void loginWithPublishPermissions( + String params, + final FBUnityLoginActivity activity) { + login(params, activity, true); + } + + public static void sendLoginSuccessMessage(AccessToken token, String callbackID) { + UnityMessage unityMessage = new UnityMessage("OnLoginComplete"); + unityMessage.put("key_hash", FB.getKeyHash()); + unityMessage.put("opened", true); + unityMessage.put("access_token", token.getToken()); + Long expiration = token.getExpires().getTime() / 1000; + unityMessage.put("expiration_timestamp", expiration.toString()); + unityMessage.put("user_id", token.getUserId()); + unityMessage.put("permissions", + TextUtils.join(",", token.getPermissions())); + unityMessage.put("declined_permissions", + TextUtils.join(",", token.getDeclinedPermissions())); + + if (callbackID != null && !callbackID.isEmpty()) { + unityMessage.put(Constants.CALLBACK_ID_KEY, callbackID); + } + + unityMessage.send(); + } + + private static void login( + String params, + final FBUnityLoginActivity activity, + boolean isPublishPermLogin) { + if (!FacebookSdk.isInitialized()) { + Log.w(FB.TAG, "Facebook SDK not initialized. Call init() before calling login()"); + return; + } + + final UnityMessage unityMessage = new UnityMessage("OnLoginComplete"); + unityMessage.put("key_hash", FB.getKeyHash()); + UnityParams unity_params = UnityParams.parse(params, + "couldn't parse login params: " + params); + + List permissions = null; + if (unity_params.hasString("scope")) { + permissions = new ArrayList<>( + Arrays.asList(unity_params.getString("scope").split(","))); + } + + String callbackIDString = null; + if (unity_params.has(Constants.CALLBACK_ID_KEY)) { + callbackIDString = unity_params.getString(Constants.CALLBACK_ID_KEY); + unityMessage.put(Constants.CALLBACK_ID_KEY, callbackIDString); + } + + final String callbackID = callbackIDString; + + // For now only web login + LoginManager.getInstance().registerCallback( + activity.getCallbackManager(), + new FacebookCallback() { + @Override + public void onSuccess(LoginResult loginResult) { + sendLoginSuccessMessage(loginResult.getAccessToken(), callbackID); + } + + @Override + public void onCancel() { + unityMessage.putCancelled(); + unityMessage.send(); + } + + @Override + public void onError(FacebookException e) { + unityMessage.sendError(e.getMessage()); + } + }); + + if (isPublishPermLogin) { + LoginManager.getInstance().logInWithPublishPermissions(activity, permissions); + } else { + LoginManager.getInstance().logInWithReadPermissions(activity, permissions); + } + } +} diff --git a/facebook-android-wrapper/src/com/facebook/unity/FBUnityAppLinkActivity.java b/facebook-android-wrapper/src/com/facebook/unity/FBUnityAppLinkActivity.java new file mode 100644 index 000000000..73e08d569 --- /dev/null +++ b/facebook-android-wrapper/src/com/facebook/unity/FBUnityAppLinkActivity.java @@ -0,0 +1,25 @@ +/** + * 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. + */ + +package com.facebook.unity; + +public class FBUnityAppLinkActivity extends FBUnityAppLinkBaseActivity { + +} diff --git a/facebook-android-wrapper/src/com/facebook/unity/FBUnityAppLinkBaseActivity.java b/facebook-android-wrapper/src/com/facebook/unity/FBUnityAppLinkBaseActivity.java new file mode 100644 index 000000000..77b53c16e --- /dev/null +++ b/facebook-android-wrapper/src/com/facebook/unity/FBUnityAppLinkBaseActivity.java @@ -0,0 +1,55 @@ +/** + * 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. + */ + +package com.facebook.unity; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; +import android.view.Window; + +public abstract class FBUnityAppLinkBaseActivity extends Activity{ + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + requestWindowFeature(Window.FEATURE_NO_TITLE); + + Log.v(FB.TAG, "Saving deep link from deep linking activity"); + FB.SetIntent(this.getIntent()); + + Log.v(FB.TAG, "Returning to main activity"); + //start main activity + Intent newIntent = new Intent(this, getMainActivityClass()); + this.startActivity(newIntent); + finish(); + } + + private Class getMainActivityClass() { + String packageName = this.getPackageName(); + Intent launchIntent = this.getPackageManager().getLaunchIntentForPackage(packageName); + try { + return Class.forName(launchIntent.getComponent().getClassName()); + } catch (Exception e) { + Log.e(FB.TAG, "Unable to find Main Activity Class"); + return null; + } + } +} diff --git a/facebook-android-wrapper/src/com/facebook/unity/FBUnityCreateGameGroupActivity.java b/facebook-android-wrapper/src/com/facebook/unity/FBUnityCreateGameGroupActivity.java new file mode 100644 index 000000000..c3291b496 --- /dev/null +++ b/facebook-android-wrapper/src/com/facebook/unity/FBUnityCreateGameGroupActivity.java @@ -0,0 +1,97 @@ +/** + * 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. + */ + +package com.facebook.unity; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; + +import com.facebook.CallbackManager; +import com.facebook.FacebookCallback; +import com.facebook.FacebookException; +import com.facebook.share.model.AppGroupCreationContent; +import com.facebook.share.model.AppGroupCreationContent.AppGroupPrivacy; +import com.facebook.share.widget.CreateAppGroupDialog; + +import java.util.Locale; + +public class FBUnityCreateGameGroupActivity extends BaseActivity { + public static String CREATE_GAME_GROUP_PARAMS = "create_game_group_params"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + AppGroupCreationContent.Builder contentBuilder = new AppGroupCreationContent.Builder(); + Bundle params = getIntent().getBundleExtra(CREATE_GAME_GROUP_PARAMS); + final UnityMessage response = new UnityMessage("OnGroupCreateComplete"); + if (params.containsKey(Constants.CALLBACK_ID_KEY)) { + response.put(Constants.CALLBACK_ID_KEY, params.getString(Constants.CALLBACK_ID_KEY)); + } + + if (params.containsKey("name")) { + contentBuilder.setName(params.getString("name")); + } + + if (params.containsKey("description")) { + contentBuilder.setDescription(params.getString("name")); + } + + if (params.containsKey("privacy")) { + String privacyStr = params.getString("privacy"); + AppGroupPrivacy privacy = AppGroupPrivacy.Closed; + if (privacyStr.equalsIgnoreCase("closed")) { + privacy = AppGroupPrivacy.Closed; + } else if (privacyStr.equalsIgnoreCase("open")) { + privacy = AppGroupPrivacy.Open; + } else { + response.sendError( + String.format( + Locale.ROOT, + "Unknown privacy setting for group creation: %s", + privacyStr)); + finish(); + } + contentBuilder.setAppGroupPrivacy(privacy); + } + + CreateAppGroupDialog dialog = new CreateAppGroupDialog(this); + dialog.registerCallback(mCallbackManager, new FacebookCallback() { + @Override + public void onSuccess(CreateAppGroupDialog.Result result) { + response.put("id", result.getId()); + response.send(); + } + + @Override + public void onCancel() { + response.putCancelled(); + response.send(); + } + + @Override + public void onError(FacebookException e) { + response.sendError(e.getLocalizedMessage()); + } + }); + dialog.show(contentBuilder.build()); + } +} diff --git a/facebook-android-wrapper/src/com/facebook/unity/FBUnityDeepLinkingActivity.java b/facebook-android-wrapper/src/com/facebook/unity/FBUnityDeepLinkingActivity.java new file mode 100644 index 000000000..86e7c9713 --- /dev/null +++ b/facebook-android-wrapper/src/com/facebook/unity/FBUnityDeepLinkingActivity.java @@ -0,0 +1,24 @@ +/** + * 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. + */ + +package com.facebook.unity; + +public class FBUnityDeepLinkingActivity extends FBUnityAppLinkBaseActivity { +} diff --git a/facebook-android-wrapper/src/com/facebook/unity/FBUnityDialogsActivity.java b/facebook-android-wrapper/src/com/facebook/unity/FBUnityDialogsActivity.java new file mode 100644 index 000000000..6e83db605 --- /dev/null +++ b/facebook-android-wrapper/src/com/facebook/unity/FBUnityDialogsActivity.java @@ -0,0 +1,97 @@ +/** + * 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. + */ + +package com.facebook.unity; + +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; + +import com.facebook.FacebookCallback; +import com.facebook.FacebookException; +import com.facebook.share.Sharer; +import com.facebook.share.model.ShareContent; +import com.facebook.share.widget.ShareDialog; + +import java.util.Locale; + +public class FBUnityDialogsActivity extends BaseActivity { + private static String TAG = FBUnityDialogsActivity.class.getName(); + public static final String DIALOG_TYPE = "dialog_type"; + public static final String SHARE_DIALOG_PARAMS = "share_dialog_params"; + public static final String FEED_DIALOG_PARAMS = "feed_dialog_params"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Intent intent = getIntent(); + ShareContent shareContent; + Bundle params; + if (intent.hasExtra(SHARE_DIALOG_PARAMS)) { + params = intent.getBundleExtra(SHARE_DIALOG_PARAMS); + shareContent = FBDialogUtils.createShareContentBuilder(params).build(); + } else if (intent.hasExtra(FEED_DIALOG_PARAMS)) { + params = intent.getBundleExtra(FEED_DIALOG_PARAMS); + shareContent = FBDialogUtils.createFeedContentBuilder(params).build(); + } else { + Log.e(TAG, + String.format( + Locale.ROOT, + "Failed to find extra %s or %s", + SHARE_DIALOG_PARAMS, + FEED_DIALOG_PARAMS)); + finish(); + return; + } + + ShareDialog dialog = new ShareDialog(this); + final UnityMessage response = new UnityMessage("OnShareLinkComplete"); + String callbackID = params.getString(Constants.CALLBACK_ID_KEY); + if (callbackID != null) { + response.put(Constants.CALLBACK_ID_KEY, callbackID); + } + + dialog.registerCallback(mCallbackManager, new FacebookCallback() { + @Override + public void onSuccess(Sharer.Result result) { + if (result.getPostId() != null) { + response.putID(result.getPostId()); + } + // Unity SDK requires to have at least one key beside callback_id. + response.put("posted", true); + response.send(); + } + + @Override + public void onCancel() { + response.putCancelled(); + response.send(); + } + + @Override + public void onError(FacebookException e) { + response.sendError(e.getMessage()); + } + }); + ShareDialog.Mode mode = (ShareDialog.Mode) getIntent().getSerializableExtra(DIALOG_TYPE); + dialog.show(shareContent, mode); + } +} diff --git a/facebook-android-wrapper/src/com/facebook/unity/FBUnityGameRequestActivity.java b/facebook-android-wrapper/src/com/facebook/unity/FBUnityGameRequestActivity.java new file mode 100644 index 000000000..3c6b6f020 --- /dev/null +++ b/facebook-android-wrapper/src/com/facebook/unity/FBUnityGameRequestActivity.java @@ -0,0 +1,119 @@ +/** + * 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. + */ + +package com.facebook.unity; + +import android.os.Bundle; +import android.text.TextUtils; + +import com.facebook.FacebookCallback; +import com.facebook.FacebookException; +import com.facebook.share.model.GameRequestContent; +import com.facebook.share.widget.GameRequestDialog; + +import java.util.Locale; + +public class FBUnityGameRequestActivity extends BaseActivity { + public static final String GAME_REQUEST_PARAMS = "game_request_params"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Bundle params = getIntent().getBundleExtra(GAME_REQUEST_PARAMS); + + final UnityMessage response = new UnityMessage("OnAppRequestsComplete"); + if (params.containsKey(Constants.CALLBACK_ID_KEY)) { + response.put(Constants.CALLBACK_ID_KEY, params.getString(Constants.CALLBACK_ID_KEY)); + } + + GameRequestContent.Builder contentBuilder = new GameRequestContent.Builder(); + if (params.containsKey("message")) { + contentBuilder.setMessage(params.getString("message")); + } + + if (params.containsKey("action_type")) { + String actionTypeStr = params.getString("action_type"); + try { + GameRequestContent.ActionType type = + GameRequestContent.ActionType.valueOf(actionTypeStr); + contentBuilder.setActionType(type); + } catch (IllegalArgumentException exception) { + response.sendError("Unknown action type: " + actionTypeStr); + return; + } + } + + if(params.containsKey("object_id")) { + contentBuilder.setObjectId(params.getString("object_id")); + + } + + if (params.containsKey("to")) { + contentBuilder.setTo(params.getString("to")); + } + + if (params.containsKey("filters")) { + String filtersStr = params.getString("filters").toUpperCase(Locale.ROOT); + try { + GameRequestContent.Filters filters = GameRequestContent.Filters.valueOf(filtersStr); + contentBuilder.setFilters(filters); + } catch (IllegalArgumentException exception) { + response.sendError("Unsupported filter type: " + filtersStr); + return; + } + } + + if (params.containsKey("data")) { + contentBuilder.setData(params.getString("data")); + } + + if (params.containsKey("title")) { + contentBuilder.setTitle(params.getString("title")); + } + + final GameRequestContent content = contentBuilder.build(); + + + GameRequestDialog requestDialog = new GameRequestDialog(this); + requestDialog.registerCallback( + mCallbackManager, + new FacebookCallback() { + @Override + public void onSuccess(GameRequestDialog.Result result) { + response.put("request", result.getRequestId()); + response.put("to", TextUtils.join(",",result.getRequestRecipients())); + response.send(); + } + + @Override + public void onCancel() { + response.putCancelled(); + response.send(); + } + + @Override + public void onError(FacebookException e) { + response.sendError(e.getMessage()); + } + }); + requestDialog.show(content); + } +} diff --git a/facebook-android-wrapper/src/com/facebook/unity/FBUnityJoinGameGroupActivity.java b/facebook-android-wrapper/src/com/facebook/unity/FBUnityJoinGameGroupActivity.java new file mode 100644 index 000000000..bdb3d5769 --- /dev/null +++ b/facebook-android-wrapper/src/com/facebook/unity/FBUnityJoinGameGroupActivity.java @@ -0,0 +1,68 @@ +/** + * 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. + */ + +package com.facebook.unity; + +import android.os.Bundle; + +import com.facebook.FacebookCallback; +import com.facebook.FacebookException; +import com.facebook.share.widget.JoinAppGroupDialog; + +public class FBUnityJoinGameGroupActivity extends BaseActivity { + public static String JOIN_GAME_GROUP_PARAMS = "join_game_group_params"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Bundle params = getIntent().getBundleExtra(JOIN_GAME_GROUP_PARAMS); + final UnityMessage response = new UnityMessage("OnJoinGroupComplete"); + if (params.containsKey(Constants.CALLBACK_ID_KEY)) { + response.put(Constants.CALLBACK_ID_KEY, params.getString(Constants.CALLBACK_ID_KEY)); + } + + String groupId = ""; + if (params.containsKey("id")) { + groupId = params.getString("id"); + } + + JoinAppGroupDialog dialog = new JoinAppGroupDialog(this); + dialog.registerCallback(mCallbackManager, new FacebookCallback() { + @Override + public void onSuccess(JoinAppGroupDialog.Result result) { + response.put("didComplete", true); + response.send(); + } + + @Override + public void onCancel() { + response.putCancelled(); + response.send(); + } + + @Override + public void onError(FacebookException e) { + response.sendError(e.getLocalizedMessage()); + } + }); + dialog.show(groupId); + } +} diff --git a/facebook-android-wrapper/src/com/facebook/unity/FBUnityLoginActivity.java b/facebook-android-wrapper/src/com/facebook/unity/FBUnityLoginActivity.java new file mode 100644 index 000000000..0bf7ad8c2 --- /dev/null +++ b/facebook-android-wrapper/src/com/facebook/unity/FBUnityLoginActivity.java @@ -0,0 +1,57 @@ +/** + * 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. + */ + +package com.facebook.unity; + +import com.facebook.CallbackManager; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; + +public class FBUnityLoginActivity extends BaseActivity { + public static final String LOGIN_PARAMS = "login_params"; + public static final String LOGIN_TYPE = "login_type"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + LoginType type = (LoginType) getIntent().getSerializableExtra(LOGIN_TYPE); + String loginParams = getIntent().getStringExtra(LOGIN_PARAMS); + switch (type) { + case READ: + FBLogin.loginWithReadPermissions(loginParams, this); + break; + case PUBLISH: + FBLogin.loginWithPublishPermissions(loginParams, this); + break; + } + } + + public CallbackManager getCallbackManager() { + return mCallbackManager; + } + + public enum LoginType { + READ, + PUBLISH + } + +} diff --git a/facebook-android-wrapper/src/com/facebook/unity/UnityCallable.java b/facebook-android-wrapper/src/com/facebook/unity/UnityCallable.java new file mode 100644 index 000000000..3b9b0b002 --- /dev/null +++ b/facebook-android-wrapper/src/com/facebook/unity/UnityCallable.java @@ -0,0 +1,29 @@ +/** + * 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. + */ + +package com.facebook.unity; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@Target({ElementType.METHOD}) +public @interface UnityCallable { + +} diff --git a/facebook-android-wrapper/src/com/facebook/unity/UnityMessage.java b/facebook-android-wrapper/src/com/facebook/unity/UnityMessage.java new file mode 100644 index 000000000..b1da638d8 --- /dev/null +++ b/facebook-android-wrapper/src/com/facebook/unity/UnityMessage.java @@ -0,0 +1,77 @@ +/** + * 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. + */ + +package com.facebook.unity; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import android.util.Log; + +public class UnityMessage { + private String methodName; + private Map params = new HashMap(); + + public UnityMessage(String methodName) { + this.methodName = methodName; + } + + public UnityMessage put(String name, Serializable value) { + params.put(name, value); + return this; + } + + public UnityMessage putCancelled() { + put("cancelled", true); + return this; + } + + public UnityMessage putID(String id) { + put("id", id); + return this; + } + + public void sendError(String errorMsg) { + this.put("error", errorMsg); + send(); + } + + public void send() { + assert methodName != null : "no method specified"; + String message = new UnityParams(this.params).toString(); + Log.v(FB.TAG, "sending to Unity " + this.methodName + "(" + message + ")"); + try { + UnityReflection.SendMessage(FB.FB_UNITY_OBJECT, this.methodName, message); + } catch (UnsatisfiedLinkError e) { + Log.v(FB.TAG, "message not send, Unity not initialized"); + } + } + + public static UnityMessage createWithCallbackFromParams( + String methodName, + UnityParams params) { + UnityMessage unityMessage = new UnityMessage(methodName); + if (params.hasString("callback_id")) { + unityMessage.put("callback_id", params.getString("callback_id")); + } + + return unityMessage; + } +} diff --git a/facebook-android-wrapper/src/com/facebook/unity/UnityParams.java b/facebook-android-wrapper/src/com/facebook/unity/UnityParams.java new file mode 100644 index 000000000..e68c1d744 --- /dev/null +++ b/facebook-android-wrapper/src/com/facebook/unity/UnityParams.java @@ -0,0 +1,132 @@ +/** + * 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. + */ + +package com.facebook.unity; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.Map; + +import org.json.JSONException; +import org.json.JSONObject; +import android.os.Bundle; +import android.util.Log; + +/** + * Wrapping JSONObject object used to communicate with Unity, catch errors, share code in one place + */ +public class UnityParams { + JSONObject json; + + public UnityParams(String s) throws JSONException { + json = new JSONObject(s); + } + + public UnityParams(JSONObject obj) { + json = obj; + } + + public UnityParams(Map map) { + json = new JSONObject(map); + } + + /* + * Parse params, log error + */ + public static UnityParams parse(String data, String msg) { + try { + return new UnityParams(data); + } catch (JSONException e) { + Log.e(FB.TAG, msg); + } + return null; + } + + public static UnityParams parse(String data) { + return parse(data, "couldn't parse params: " + data); + } + + public String getString(String key) { + try { + return json.getString(key); + } catch (JSONException e) { + Log.e(FB.TAG, "cannot get string " + key + " from " + this.toString()); + return ""; + } + } + + public double getDouble(String key) { + try { + return json.getDouble(key); + } catch (JSONException e) { + Log.e(FB.TAG, "cannot get double " + key + " from " + this.toString()); + return 0; + } + } + + public UnityParams getParamsObject(String key) { + try { + return new UnityParams(json.getJSONObject(key)); + } catch (JSONException e) { + Log.e(FB.TAG, "cannot get object " + key + " from " + this.toString()); + return null; + } + } + + public void put(String name, Object value) { + try { + json.put(name, value); + } catch (JSONException e) { + Log.e(FB.TAG, "couldn't add key " + name + " to " + this.toString()); + } + } + + public boolean has(String key) { + return json.has(key) && !json.isNull(key); + } + + public Boolean hasString(String key) { + return this.has(key) && this.getString(key) != ""; + } + + /* + * Gets all the string keys from JSON object + */ + public Bundle getStringParams() { + Bundle result = new Bundle(); + Iterator keys = json.keys(); + while(keys.hasNext()) { + String key = (String)keys.next(); + try { + String value = json.getString(key); + if (value != null) { + result.putString(key, value); + } + } catch (JSONException e) { + } + } + return result; + } + + public String toString() { + return json.toString(); + } + +} diff --git a/facebook-android-wrapper/src/com/facebook/unity/UnityReflection.java b/facebook-android-wrapper/src/com/facebook/unity/UnityReflection.java new file mode 100644 index 000000000..f48e62ef7 --- /dev/null +++ b/facebook-android-wrapper/src/com/facebook/unity/UnityReflection.java @@ -0,0 +1,66 @@ +/** + * 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. + */ + +package com.facebook.unity; + +import android.app.Activity; +import android.util.Log; + +import java.lang.reflect.Method; + +/** + * This class is a hack. Currently we can't have both the interative console and this + * aar include the unity_classes.jar. Unity will fail to build due to the duplicate jar to + * get around this we use reflection instead. + */ +public class UnityReflection { + private static Class unityPlayer; + + public static void SendMessage(String unityObject, String unityMethod, String message) { + try { + if (unityPlayer == null) { + unityPlayer = Class.forName("com.unity3d.player.UnityPlayer"); + } + + Method method = unityPlayer.getMethod( + "UnitySendMessage", String.class, String.class, String.class); + method.invoke(unityPlayer, unityObject, unityMethod, message); + } catch (Exception ex) { + Log.d("TODO", ex.toString()); + } + } + + public static Activity GetUnityActivity() { + try { + if (unityPlayer == null) { + unityPlayer = Class.forName("com.unity3d.player.UnityPlayer"); + } + + Activity activity = (Activity) unityPlayer.getField("currentActivity").get(null); + if (activity == null) { + Log.d(FB.TAG, "Current unity activity is null"); + } + return activity; + } catch (Exception ex) { + Log.d(FB.TAG, ex.toString()); + return null; + } + } +} diff --git a/scripts/build.properties b/scripts/build.properties new file mode 100644 index 000000000..ac2080add --- /dev/null +++ b/scripts/build.properties @@ -0,0 +1,28 @@ +# 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 + +FB_ANDROID_SDK_GROUP_ID='com.facebook.android' +FB_ANDROID_SDK_ARTIFACT_ID='facebook-android-sdk' +FB_ANDROID_SDK_VERSION='4.6.0' +FB_ANDROID_SDK_PACKAGING='aar' +BOLTS_GROUP_ID='com.parse.bolts' +BOLTS_ARTIFACT_ID='bolts-android' +BOLTS_VERSION='1.2.0' +BOLTS_PACKAGING='jar' + +FB_IOS_RESOURCE_NAME='FacebookSDKs-iOS-20150910.zip' +FB_IOS_SDK_VERSION='4.6.0' diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 000000000..ad42c24e6 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# +# 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 + +# This file performs the custom build logic to setup the Plugins +# in the unity project + +. $(dirname $0)/common.sh + +$SCRIPTS_DIR/setup_ios_unity_plugin.sh || die "Failed to setup the ios sdk plugin" +$SCRIPTS_DIR/setup_android_unity_plugin.sh || die "Failed to build the android sdk plugin" diff --git a/scripts/common.sh b/scripts/common.sh new file mode 100755 index 000000000..f13d25a7f --- /dev/null +++ b/scripts/common.sh @@ -0,0 +1,86 @@ +#!/bin/sh +# +# 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 + +cd "$( dirname "${BASH_SOURCE[0]}" )/.." +PROJECT_ROOT=$(pwd) +UNITY_PACKAGE_ROOT=$PROJECT_ROOT/Facebook.Unity +SCRIPTS_DIR="$PROJECT_ROOT/scripts" + +RED='\033[0;31m' +NC='\033[0m' +CYAN='\033[0;36m' + +# Load settings +source $PROJECT_ROOT/scripts/build.properties +LOCAL_PROPS=$PROJECT_ROOT/scripts/local.properties +if [ -f "$LOCAL_PROPS" ]; then + source $PROJECT_ROOT/scripts/local.properties +else + echo "No properties file found at $LOCAL_PROPS" +fi + +# Extract the SDK version from FacebookSdkVersion.java +SDK_VERSION_RAW=$(sed -n 's/.*"\(.*\)\";/\1/p' "$UNITY_PACKAGE_ROOT/Assets/Facebook/Scripts/FacebookSdkVersion.cs") +SDK_VERSION_MAJOR=$(echo $SDK_VERSION_RAW | awk -F'.' '{print $1}') +SDK_VERSION_MAJOR=${SDK_VERSION_MAJOR:-0} +SDK_VERSION_MINOR=$(echo $SDK_VERSION_RAW | awk -F'.' '{print $2}') +SDK_VERSION_MINOR=${SDK_VERSION_MINOR:-0} +SDK_VERSION_REVISION=$(echo $SDK_VERSION_RAW | awk -F'.' '{print $3}') +SDK_VERSION_REVISION=${SDK_VERSION_REVISION:-0} +SDK_VERSION=$SDK_VERSION_MAJOR.$SDK_VERSION_MINOR.$SDK_VERSION_REVISION +SDK_VERSION_SHORT=$(echo $SDK_VERSION | sed 's/\.0$//') + +OUT="$PROJECT_ROOT/out" +DEV_SERVER=$(whoami).sb.facebook.com +MAVEN_BASE_URL='http://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=%s&a=%s&p=%s&v=%s' + +function die() { + echo "" + echo "${RED}FATAL: $* ${NC}" >&2 + exit 1 +} + +# Echoes a progress message to stderr +function progress_message() { + echo "$@" >&2 +} + +function info() { + echo "${CYAN}$* ${NC}" >&2 +} + +function downloadFromMaven() { + GROUP_ID=$1 + ARTIFACT_ID=$2 + PACKAGING=$3 + VERSION=$4 + MAVEN_DOWNLOAD_URL=$(printf "$MAVEN_BASE_URL" "$GROUP_ID" "$ARTIFACT_ID" "$PACKAGING" "$VERSION") + + OUTPUT_PATH=$5 + curl -L "$MAVEN_DOWNLOAD_URL" -o "$OUTPUT_PATH" || die "Failed download $MAVEN_DOWNLOAD_URL" +} + +function add_resource() { + RES=$1 + scp $OUT/$RES ${DEV_SERVER}:/tmp/$RES \ + || die "Error copying $RES to ${DEV_SERVER}:/tmp/$RES" + ssh $DEV_SERVER '~/www/scripts/developer/resource_admin' add /tmp/$RES >/tmp/$RES.handle.txt \ + || die "Error running resource_admin add $RES" + echo "$RES handle: $(cat /tmp/$RES.handle.txt)" +} diff --git a/scripts/setup_android_unity_plugin.sh b/scripts/setup_android_unity_plugin.sh new file mode 100755 index 000000000..069180529 --- /dev/null +++ b/scripts/setup_android_unity_plugin.sh @@ -0,0 +1,115 @@ +#!/bin/sh +# +# 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 + +. $(dirname $0)/common.sh + +info "Starting build" +# Check for required settings +if [ -z "$ANDROID_HOME" ]; then + echo "${RED}ERROR: ANDROID_HOME environment variable not set${NC}" + echo "${RED}Please set the ANDROID_HOME environment variable to point to your android sdk${NC}" + exit 1 +fi + +localBuild=false +if [[ $* == *--local* ]]; then + localBuild=true +fi + +# Copy the required libs +UNITY_PLUGIN_FACEBOOK="$UNITY_PACKAGE_ROOT/Assets/Plugins/Android/libs/" + +FB_WRAPPER_PATH=$PROJECT_ROOT/facebook-android-wrapper +FB_WRAPPER_LIB_PATH=$FB_WRAPPER_PATH/libs +FB_ANDROID_SDK_WRAPPER="$FB_WRAPPER_PATH/build/outputs/aar/facebook-android-wrapper-release.aar" + +FB_SDK_AAR_NAME="$FB_ANDROID_SDK_ARTIFACT_ID-$FB_ANDROID_SDK_VERSION.$FB_ANDROID_SDK_PACKAGING" +FB_SDK_AAR_PATH="$FB_WRAPPER_LIB_PATH/$FB_SDK_AAR_NAME" + +BOLTS_SDK_JAR_NAME="$BOLTS_ARTIFACT_ID-$BOLTS_VERSION.jar" +BOLTS_JAR_PATH="$FB_WRAPPER_LIB_PATH/$BOLTS_SDK_JAR_NAME" + +ANDROID_SUPPORT_LIB_PATH="$ANDROID_HOME/extras/android/support/v4/android-support-v4.jar" + +# Local build only properties +FB_ANDROID_SDK_AAR="$FB_ANDROID_SDK_PATH/facebook/build/outputs/aar/facebook-release.aar" + +info "Step 1 - Cleaning wrapper libs folder" +if [ ! -d "$FB_WRAPPER_LIB_PATH" ]; then + mkdir -p $FB_WRAPPER_LIB_PATH || die "Failed to create wrapper libs folder" +fi +pushd "$FB_WRAPPER_LIB_PATH" || die "Cannot navigate to directory $FB_WRAPPER_LIB_PATH" +# Only delete everything except the expected bolts and sdk versions +find . ! -name $BOLTS_SDK_JAR_NAME ! -name $FB_SDK_AAR_NAME -maxdepth 1 -type f -delete +popd + +info "Step 2 - Get depenancies for android wrapper" +info "Step 2.1 - Download $BOLTS_SDK_JAR_NAME" +if [ ! -f "$BOLTS_JAR_PATH" ]; then + downloadFromMaven $BOLTS_GROUP_ID $BOLTS_ARTIFACT_ID $BOLTS_PACKAGING $BOLTS_VERSION "$BOLTS_JAR_PATH" +else + info "$BOLTS_SDK_JAR_NAME already exists. Skipping download." +fi + +# Get the android sdk +if [ "$localBuild" = true ]; then + info "Step 2.2.0 - Build local android sdk at '$FB_ANDROID_SDK_PATH'" + pushd $FB_ANDROID_SDK_PATH + ./gradlew :facebook:assemble || die "Failed to build facebook sdk" + popd + info "Step 2.2.1 - Copy FB_ANDROID_SDK_PATH to lib folder" + cp $FB_ANDROID_SDK_AAR $FB_SDK_AAR_PATH || die "Failed to copy sdk to wrapper libs folder" +else + info "Step 2.2 - Download $FB_SDK_AAR_NAME" + if [ ! -f "$FB_SDK_AAR_PATH" ]; then + downloadFromMaven $FB_ANDROID_SDK_GROUP_ID $FB_ANDROID_SDK_ARTIFACT_ID $FB_ANDROID_SDK_PACKAGING $FB_ANDROID_SDK_VERSION "$FB_SDK_AAR_PATH" + else + info "$FB_SDK_AAR_NAME already exists. Skipping download" + fi +fi + +info "Step 2.3 - Coping support lib" +cp "$ANDROID_SUPPORT_LIB_PATH" $FB_WRAPPER_LIB_PATH || die "Failed to copy '$ANDROID_SUPPORT_LIB_PATH'" + +info "Step 3 - Build android wrapper" +pushd $FB_WRAPPER_PATH +./gradlew clean || die "Failed to perform gradle clean" +if [ "$localBuild" = true ]; then + ./gradlew assemble -PlocalRepo=libs -PsdkVersion=$FB_ANDROID_SDK_VERSION || die "Failed to build facebook android wrapper" +else + ./gradlew assemble -PsdkVersion=$FB_ANDROID_SDK_VERSION || die "Failed to build facebook android wrapper" +fi +popd + +info "Step 4 - Copy libs to unity plugin folder" +if [ ! -d "$UNITY_PLUGIN_FACEBOOK" ]; then + mkdir -p $UNITY_PLUGIN_FACEBOOK || die "Failed to make unity plugin lib folder" +fi +# clean the unity lib folder +rm -r -f $UNITY_PLUGIN_FACEBOOK/* +# Copy aars +cp $FB_SDK_AAR_PATH $UNITY_PLUGIN_FACEBOOK || die 'Failed to copy fb sdk to unity plugin folders' +cp $FB_ANDROID_SDK_WRAPPER $UNITY_PLUGIN_FACEBOOK || die 'Failed to copy wrapper to unity plugin folder' +if [ "$localBuild" = false ]; then + # For local builds the jars are included in the wrapper for maven builds we have to copy them over + cp $BOLTS_JAR_PATH $UNITY_PLUGIN_FACEBOOK || die 'Failed to copy bolts jar to unity plugin folder' + cp $ANDROID_SUPPORT_LIB_PATH $UNITY_PLUGIN_FACEBOOK || die 'Failed to copy support lib to unity plugin folder' +fi + +info "Done!" diff --git a/scripts/setup_ios_unity_plugin.sh b/scripts/setup_ios_unity_plugin.sh new file mode 100755 index 000000000..ad9ad7082 --- /dev/null +++ b/scripts/setup_ios_unity_plugin.sh @@ -0,0 +1,63 @@ +#!/bin/sh +# +# 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 + +. $(dirname $0)/common.sh + +cd $(dirname $0)/.. +PROJECT_ROOT=$(pwd) +PROPS_PATH="$PROJECT_ROOT/scripts/build.properties" +source $PROPS_PATH + +rm -rf tempIosBuild +mkdir tempIosBuild +cd tempIosBuild + +UNITY_PLUGIN_FACEBOOK="$UNITY_PACKAGE_ROOT/Assets/Plugins/iOS/Facebook" +mkdir -p "$UNITY_PLUGIN_FACEBOOK" +rm -rf "$UNITY_PLUGIN_FACEBOOK/*" + +if [[ $* == *--local* ]]; then + info "Local build selected" + if [ -z "$FB_IOS_SDK_PATH" ]; then + die "Please set the FB_IOS_SDK_PATH variable in $LOCAL_PROPS" + fi + sdkFolder="$FB_IOS_SDK_PATH" +else + if [ -z "$FB_IOS_SDK_VERSION" ]; then + echo "${RED}Error: 'FB_IOS_SDK_VERSION' not defined in $PROPS_PATH ${NC}" + exit 1 + fi + + if [ -z "$FB_IOS_RESOURCE_NAME" ]; then + echo "${RED}Error: 'FB_IOS_RESOURCE_NAME' not defined in $PROPS_PATH ${NC}" + exit 1 + fi + packageName="facebook-ios-sdk-$FB_IOS_SDK_VERSION" + curl -L "http://fb.me/$FB_IOS_RESOURCE_NAME" -o "$packageName.zip" + + unzip -q "$packageName.zip" -d $packageName + sdkFolder="$PROJECT_ROOT/tempIosBuild/$packageName" +fi + +for FRAMEWORK in FBSDKCoreKit.framework FBSDKLoginKit.framework FBSDKShareKit.framework Bolts.framework; do + cp -r -f "$sdkFolder/$FRAMEWORK" "$UNITY_PLUGIN_FACEBOOK" || die "failed to copy $FRAMEWORK" +done + +cd $PROJECT_ROOT +rm -r -f tempIosBuild