diff --git a/LICENSE b/LICENSE index 3423e95..8578115 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,5 @@ +The Windows SDK for Facebook is licensed under the following terms: + The MIT License (MIT) Copyright (c) 2015 Microsoft @@ -19,3 +21,25 @@ 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. + +-------------------------------------------------------------------------------- +The Facebook SDK App Events code is licensed under the following terms: + +Copyright(c) 2016, 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.md b/README.md index 0da156a..def66f8 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,15 @@ The Windows SDK for Facebook is geared towards app developers creating modern wi - Upload Photo - Like a Page/Object +###AppInstalls + - Mobile App Installs (can be disabled by defining \_\_NOFBAPPEVENTS__) + ## **Supported Platforms** Windows 8.1+ Windows Phone 8.1+ -Windows 10 Technical Preview +Windows 10 ## **Documentation** diff --git a/winsdkfb/winsdkfb/winsdkfb.Shared/FBConstants.h b/winsdkfb/winsdkfb/winsdkfb.Shared/FBConstants.h index 15ae87c..0a5f3a9 100644 --- a/winsdkfb/winsdkfb/winsdkfb.Shared/FBConstants.h +++ b/winsdkfb/winsdkfb/winsdkfb.Shared/FBConstants.h @@ -19,3 +19,7 @@ #define FACEBOOK_DESKTOP_SERVER_NAME L"https://www.facebook.com" #define FACEBOOK_MOBILE_SERVER_NAME L"https://m.facebook.com" #define FACEBOOK_LOGIN_SUCCESS_PATH L"/connect/login_success.html" + +// Define the base version of the SDK. +// Keep in sync with winsdkfb\build\nuget\VERSION +#define WINSDKFB_VERSION L"0.9" diff --git a/winsdkfb/winsdkfb/winsdkfb.Shared/FacebookClient.cpp b/winsdkfb/winsdkfb/winsdkfb.Shared/FacebookClient.cpp index bd58d8f..d3d44e9 100644 --- a/winsdkfb/winsdkfb/winsdkfb.Shared/FacebookClient.cpp +++ b/winsdkfb/winsdkfb/winsdkfb.Shared/FacebookClient.cpp @@ -49,7 +49,8 @@ using namespace Windows::Web::Http::Headers; #define MultiPartContentType L"Content-Type: multipart/form-data; " #define MultiPartBoundary L"------------------------------fbsdk1234567890" #define UserAgent L"User-Agent" -#define WinSDK L"FBWinSDK.0.9" +#define WinSDKFBUserAgent(version) L"winsdkfb." version +#define WinSDKFBUserAgentString WinSDKFBUserAgent(WINSDKFB_VERSION) FBClient::FBClient() { @@ -141,7 +142,7 @@ task FBClient::GetTaskInternalAsync( { HttpBaseProtocolFilter^ filter = ref new HttpBaseProtocolFilter(); HttpClient^ httpClient = ref new HttpClient(filter); - httpClient->DefaultRequestHeaders->Append(UserAgent, WinSDK); + httpClient->DefaultRequestHeaders->Append(UserAgent, WinSDKFBUserAgentString); cancellation_token_source cancellationTokenSource = cancellation_token_source(); @@ -223,7 +224,7 @@ task FBClient::SimplePostInternalAsync( { HttpBaseProtocolFilter^ filter = ref new HttpBaseProtocolFilter(); HttpClient^ httpClient = ref new HttpClient(filter); - httpClient->DefaultRequestHeaders->Append(UserAgent, WinSDK); + httpClient->DefaultRequestHeaders->Append(UserAgent, WinSDKFBUserAgentString); cancellation_token_source cancellationTokenSource = cancellation_token_source(); @@ -303,7 +304,7 @@ task FBClient::MultipartPostInternalAsync( ) { HttpClient^ httpClient = ref new HttpClient(); - httpClient->DefaultRequestHeaders->Append(UserAgent, WinSDK); + httpClient->DefaultRequestHeaders->Append(UserAgent, WinSDKFBUserAgentString); HttpMultipartFormDataContent^ form = ref new HttpMultipartFormDataContent(); cancellation_token_source cancellationTokenSource = @@ -380,7 +381,7 @@ task FBClient::DeleteTaskInternalAsync( { HttpBaseProtocolFilter^ filter = ref new HttpBaseProtocolFilter(); HttpClient^ httpClient = ref new HttpClient(filter); - httpClient->DefaultRequestHeaders->Append(UserAgent, WinSDK); + httpClient->DefaultRequestHeaders->Append(UserAgent, WinSDKFBUserAgentString); cancellation_token_source cancellationTokenSource = cancellation_token_source(); diff --git a/winsdkfb/winsdkfb_uwp/winsdkfb_uwp/FBSDKAppEvents.cpp b/winsdkfb/winsdkfb_uwp/winsdkfb_uwp/FBAppEvents/FacebookAppEvents.cpp similarity index 83% rename from winsdkfb/winsdkfb_uwp/winsdkfb_uwp/FBSDKAppEvents.cpp rename to winsdkfb/winsdkfb_uwp/winsdkfb_uwp/FBAppEvents/FacebookAppEvents.cpp index e4afe5a..8cafa0a 100644 --- a/winsdkfb/winsdkfb_uwp/winsdkfb_uwp/FBSDKAppEvents.cpp +++ b/winsdkfb/winsdkfb_uwp/winsdkfb_uwp/FBAppEvents/FacebookAppEvents.cpp @@ -1,29 +1,30 @@ //****************************************************************************** // -// Copyright(c) 2016, Facebook, Inc.All rights reserved. +// Copyright(c) 2016, 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 +// 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. +// 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 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 "pch.h" -#include "FBSDKAppEvents.h" +#ifndef __NOFBAPPEVENTS__ + +#include "FacebookAppEvents.h" #include "FacebookClient.h" using namespace concurrency; @@ -40,32 +41,38 @@ using namespace Windows::Globalization; using namespace Windows::Storage; using namespace Windows::System::UserProfile; -#define FBActivitiesPath L"/activities" -#define FBMobileAppInstall L"MOBILE_APP_INSTALL" -#define FBCustomAppEvent L"CUSTOM_APP_EVENTS" -#define FBAppIDName L"FBApplicationId" +// Constants +#define FACEBOOK_ACTIVITIES_PATH L"/activities" +#define FACEBOOK_MOBILE_APP_INSTALL L"MOBILE_APP_INSTALL" +#define FACEBOOK_CUSTOM_APP_EVENTS L"CUSTOM_APP_EVENTS" +#define FACEBOOK_APPID_NAME L"FBApplicationId" + + /* -* To integrate install tracking for mobile app install ads, -* call this method when the app is launched. + * To integrate install tracking for mobile app install ads, + * call this method when the app is launched. */ void FBSDKAppEvents::ActivateApp() { // Try to grab the application id from resource file. String^ appId; - try { + try + { ResourceLoader^ rl = ResourceLoader::GetForCurrentView(); - appId = rl->GetString(FBAppIDName); + appId = rl->GetString(FACEBOOK_APPID_NAME); } - catch (Exception^ e) { + catch (Exception^ e) + { throw ref new NotImplementedException( - FBAppIDName + L" needs to be added to resource file." + FACEBOOK_APPID_NAME + L" needs to be added to resource file." ); } - if (!appId) { + if (!appId) + { throw ref new NotImplementedException( - FBAppIDName + L" cannot contain empty value" + FACEBOOK_APPID_NAME + L" cannot contain empty value" ); } @@ -77,6 +84,7 @@ void FBSDKAppEvents::ActivateApp() * Publish an install event to the Facebook graph endpoint. * Write the timestamp to localSettings so we only trigger this once. */ + IAsyncAction^ FBSDKAppEvents::PublishInstall( String^ AppId ) @@ -127,9 +135,9 @@ IAsyncOperation^ FBSDKAppEvents::LogInstallEvent( String^ AppId ) { - String^ path = AppId + FBActivitiesPath; + String^ path = AppId + FACEBOOK_ACTIVITIES_PATH; PropertySet^ parameters = ref new PropertySet(); - parameters->Insert(L"event", FBMobileAppInstall); + parameters->Insert(L"event", FACEBOOK_MOBILE_APP_INSTALL); parameters->Insert(L"advertiser_id", AdvertisingManager::AdvertisingId); parameters->Insert( L"advertiser_tracking_enabled", @@ -157,9 +165,9 @@ IAsyncAction^ FBSDKAppEvents::LogActivateEvent( String^ AppId ) { - String^ path = AppId + FBActivitiesPath; + String^ path = AppId + FACEBOOK_ACTIVITIES_PATH; PropertySet^ parameters = ref new PropertySet(); - parameters->Insert(L"event", FBCustomAppEvent); + parameters->Insert(L"event", FACEBOOK_CUSTOM_APP_EVENTS); parameters->Insert(L"custom_events", FBSDKAppEvents::GetActivateAppJson()); parameters->Insert(L"advertiser_id", AdvertisingManager::AdvertisingId); parameters->Insert( @@ -183,7 +191,8 @@ IAsyncAction^ FBSDKAppEvents::LogActivateEvent( /* * Creates a JSON array encapsulating the activate app event */ -String^ FBSDKAppEvents::GetActivateAppJson() { +String^ FBSDKAppEvents::GetActivateAppJson() +{ JsonArray^ customEvents = ref new JsonArray(); JsonObject^ activateJson = ref new JsonObject(); activateJson->SetNamedValue( @@ -192,4 +201,6 @@ String^ FBSDKAppEvents::GetActivateAppJson() { ); customEvents->Append(activateJson); return customEvents->ToString(); -} \ No newline at end of file +} + +#endif //__NOFBAPPEVENTS__ \ No newline at end of file diff --git a/winsdkfb/winsdkfb_uwp/winsdkfb_uwp/FBSDKAppEvents.h b/winsdkfb/winsdkfb_uwp/winsdkfb_uwp/FBAppEvents/FacebookAppEvents.h similarity index 55% rename from winsdkfb/winsdkfb_uwp/winsdkfb_uwp/FBSDKAppEvents.h rename to winsdkfb/winsdkfb_uwp/winsdkfb_uwp/FBAppEvents/FacebookAppEvents.h index 1e33ebd..5bd4946 100644 --- a/winsdkfb/winsdkfb_uwp/winsdkfb_uwp/FBSDKAppEvents.h +++ b/winsdkfb/winsdkfb_uwp/winsdkfb_uwp/FBAppEvents/FacebookAppEvents.h @@ -1,48 +1,77 @@ //****************************************************************************** // -// Copyright(c) 2016, Facebook, Inc.All rights reserved. +// Copyright(c) 2016, 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 +// 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. +// 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 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. // //****************************************************************************** #pragma once +#ifndef __NOFBAPPEVENTS__ + namespace winsdkfb { public ref class FBSDKAppEvents sealed { public: + /** + * To integrate install tracking for mobile app install ads, + * call this method when the app is launched. + */ static void ActivateApp(); private: + /** + * Publish an install event to the Facebook graph endpoint. + * Write the timestamp to localSettings so we only trigger this once. + * @param The Application Id for the request + * @return The IAsyncAction that can be waited on for the completion + */ static Windows::Foundation::IAsyncAction^ PublishInstall( Platform::String^ AppId ); + /** + * Logs a custom app event to the Facebook graph endpoint. + * @param The Application Id for the request + * @return The IAsyncAction that can be waited on for the completion + */ static Windows::Foundation::IAsyncAction^ LogActivateEvent( Platform::String^ AppId ); + /* + * Logs an install event to the Facebook graph endpoint. + * The user will be looked up using idfa or windows_attribution_id + * @param The Application Id for the request + * @return The HTTP response from the request + */ static Windows::Foundation::IAsyncOperation^ LogInstallEvent( Platform::String^ AppId ); + /* + * Creates a JSON array encapsulating the activate app event + * @return The JSON string for the event + */ static Platform::String^ GetActivateAppJson(); }; -} \ No newline at end of file +} + +#endif diff --git a/winsdkfb/winsdkfb_uwp/winsdkfb_uwp/winsdkfb_uwp.vcxproj b/winsdkfb/winsdkfb_uwp/winsdkfb_uwp/winsdkfb_uwp.vcxproj index efbd108..541a1b6 100644 --- a/winsdkfb/winsdkfb_uwp/winsdkfb_uwp/winsdkfb_uwp.vcxproj +++ b/winsdkfb/winsdkfb_uwp/winsdkfb_uwp/winsdkfb_uwp.vcxproj @@ -27,10 +27,10 @@ - + - + {973a943b-ff77-4267-8f30-f5fe2b7f5583} diff --git a/winsdkfb/winsdkfb_uwp/winsdkfb_uwp/winsdkfb_uwp.vcxproj.filters b/winsdkfb/winsdkfb_uwp/winsdkfb_uwp/winsdkfb_uwp.vcxproj.filters index 3afda26..3a24e81 100644 --- a/winsdkfb/winsdkfb_uwp/winsdkfb_uwp/winsdkfb_uwp.vcxproj.filters +++ b/winsdkfb/winsdkfb_uwp/winsdkfb_uwp/winsdkfb_uwp.vcxproj.filters @@ -11,15 +11,18 @@ {0c41c025-6e0c-405d-b80a-46adadface88} + + {b3d7b624-4dcc-402e-9b67-9ffb472d03f0} + - - Header Files + + FBSDKAppEvents - - Source Files + + FBSDKAppEvents \ No newline at end of file