From e2b10bb2efbe6a176386092f2534e8beb4f1e885 Mon Sep 17 00:00:00 2001 From: Vijaye Raji Date: Mon, 24 Sep 2012 18:33:20 -0700 Subject: [PATCH] Adding support for sending Advertising identifier for conversion purposes Summary: On iOS6 and above, we can use Apple's blesssed Advertising Identifier for install conversion purposes. Since we are not using this for tracking/targeted advertising purposes, we don't have to check the "limit targeting" setting. (reference: https://developer.apple.com/library/ios/#documentation/AdSupport/Reference/ASIdentifierManager_Ref/ASIdentifierManager.html#//apple_ref/doc/uid/TP40012654) Test Plan: Ran Scrumptious on a clean simulator and verified that the ad-id is being captured and sent. Reviewers: jacl, mmarucheck, clang Reviewed By: jacl CC: jketchpaw, msdkexp@ Differential Revision: https://phabricator.fb.com/D583190 --- .../BooleanOGSample.xcodeproj/project.pbxproj | 4 + .../project.pbxproj | 4 + .../Hackbook.xcodeproj/project.pbxproj | 4 + .../project.pbxproj | 4 + .../project.pbxproj | 4 + .../project.pbxproj | 4 + .../project.pbxproj | 4 + .../Scrumptious.xcodeproj/project.pbxproj | 4 + .../project.pbxproj | 4 + .../project.pbxproj | 4 + src/FBRequest.m | 2 +- src/FBSettings.m | 141 ++++++++++-------- .../project.pbxproj | 6 + 13 files changed, 128 insertions(+), 61 deletions(-) diff --git a/samples/BooleanOGSample/BooleanOGSample.xcodeproj/project.pbxproj b/samples/BooleanOGSample/BooleanOGSample.xcodeproj/project.pbxproj index 086b09b070..5941a3718d 100644 --- a/samples/BooleanOGSample/BooleanOGSample.xcodeproj/project.pbxproj +++ b/samples/BooleanOGSample/BooleanOGSample.xcodeproj/project.pbxproj @@ -32,6 +32,7 @@ 85C69D741602B098008AD9A0 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69D711602B098008AD9A0 /* Default-568h@2x.png */; }; 85C69D751602B098008AD9A0 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69D721602B098008AD9A0 /* Default.png */; }; 85C69D761602B098008AD9A0 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69D731602B098008AD9A0 /* Default@2x.png */; }; + B9A4167216113E93001E7A77 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9A4167116113E93001E7A77 /* AdSupport.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; DD37EA7F15ABA42D0015966B /* FacebookSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD37EA7E15ABA42D0015966B /* FacebookSDK.framework */; }; DE1C9C2A15CC8F9A00809B9E /* FacebookSDKResources.bundle in Resources */ = {isa = PBXBuildFile; fileRef = DE1C9C2915CC8F9A00809B9E /* FacebookSDKResources.bundle */; }; DE1C9C2C15CC8FE400809B9E /* FBUserSettingsViewResources.bundle in Resources */ = {isa = PBXBuildFile; fileRef = DE1C9C2B15CC8FE400809B9E /* FBUserSettingsViewResources.bundle */; }; @@ -70,6 +71,7 @@ 85C69D711602B098008AD9A0 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 85C69D721602B098008AD9A0 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 85C69D731602B098008AD9A0 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; + B9A4167116113E93001E7A77 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; }; DD37EA7E15ABA42D0015966B /* FacebookSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FacebookSDK.framework; path = ../../build/FacebookSDK.framework; sourceTree = ""; }; DE1C9C2915CC8F9A00809B9E /* FacebookSDKResources.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = FacebookSDKResources.bundle; path = ../../build/FacebookSDK.framework/Versions/A/Resources/FacebookSDKResources.bundle; sourceTree = ""; }; DE1C9C2B15CC8FE400809B9E /* FBUserSettingsViewResources.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = FBUserSettingsViewResources.bundle; path = ../../build/FacebookSDK.framework/Versions/A/Resources/FBUserSettingsViewResources.bundle; sourceTree = ""; }; @@ -81,6 +83,7 @@ buildActionMask = 2147483647; files = ( 85A928C716114684008699F1 /* Social.framework in Frameworks */, + B9A4167216113E93001E7A77 /* AdSupport.framework in Frameworks */, 84605AB615A77C9300197AA7 /* Accounts.framework in Frameworks */, 84070D1B1540AA2B00E39703 /* UIKit.framework in Frameworks */, 84070D1D1540AA2B00E39703 /* Foundation.framework in Frameworks */, @@ -113,6 +116,7 @@ 84070D191540AA2B00E39703 /* Frameworks */ = { isa = PBXGroup; children = ( + B9A4167116113E93001E7A77 /* AdSupport.framework */, DE1C9C2B15CC8FE400809B9E /* FBUserSettingsViewResources.bundle */, DE1C9C2915CC8F9A00809B9E /* FacebookSDKResources.bundle */, DD37EA7E15ABA42D0015966B /* FacebookSDK.framework */, diff --git a/samples/FriendPickerSample/FriendPickerSample.xcodeproj/project.pbxproj b/samples/FriendPickerSample/FriendPickerSample.xcodeproj/project.pbxproj index c3f26b9ed5..e1ead81431 100644 --- a/samples/FriendPickerSample/FriendPickerSample.xcodeproj/project.pbxproj +++ b/samples/FriendPickerSample/FriendPickerSample.xcodeproj/project.pbxproj @@ -16,6 +16,7 @@ 85C69D7F1602B0AF008AD9A0 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69D7C1602B0AF008AD9A0 /* Default-568h@2x.png */; }; 85C69D801602B0AF008AD9A0 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69D7D1602B0AF008AD9A0 /* Default.png */; }; 85C69D811602B0AF008AD9A0 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69D7E1602B0AF008AD9A0 /* Default@2x.png */; }; + B9A4167916113EAE001E7A77 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9A4167816113EAE001E7A77 /* AdSupport.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; DD37EA8615ABA4670015966B /* FacebookSDKResources.bundle in Resources */ = {isa = PBXBuildFile; fileRef = DD37EA8515ABA4670015966B /* FacebookSDKResources.bundle */; }; DD37EA8815ABA46B0015966B /* FacebookSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD37EA8715ABA46B0015966B /* FacebookSDK.framework */; }; E2D6B81315413A570050835F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E2D6B81215413A570050835F /* UIKit.framework */; }; @@ -39,6 +40,7 @@ 85C69D7C1602B0AF008AD9A0 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 85C69D7D1602B0AF008AD9A0 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 85C69D7E1602B0AF008AD9A0 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; + B9A4167816113EAE001E7A77 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; }; DD37EA8515ABA4670015966B /* FacebookSDKResources.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = FacebookSDKResources.bundle; path = ../../build/FacebookSDK.framework/Versions/A/Resources/FacebookSDKResources.bundle; sourceTree = ""; }; DD37EA8715ABA46B0015966B /* FacebookSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FacebookSDK.framework; path = ../../build/FacebookSDK.framework; sourceTree = ""; }; E2D6B80E15413A570050835F /* FriendPickerSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FriendPickerSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -63,6 +65,7 @@ buildActionMask = 2147483647; files = ( 85A928B91611462C008699F1 /* Social.framework in Frameworks */, + B9A4167916113EAE001E7A77 /* AdSupport.framework in Frameworks */, 84605AB315A77C2700197AA7 /* Accounts.framework in Frameworks */, E2D6B81315413A570050835F /* UIKit.framework in Frameworks */, E2D6B81515413A570050835F /* Foundation.framework in Frameworks */, @@ -95,6 +98,7 @@ E2D6B81115413A570050835F /* Frameworks */ = { isa = PBXGroup; children = ( + B9A4167816113EAE001E7A77 /* AdSupport.framework */, DD37EA8515ABA4670015966B /* FacebookSDKResources.bundle */, DD37EA8715ABA46B0015966B /* FacebookSDK.framework */, 84605AB215A77C2700197AA7 /* Accounts.framework */, diff --git a/samples/Hackbook/Hackbook.xcodeproj/project.pbxproj b/samples/Hackbook/Hackbook.xcodeproj/project.pbxproj index ac7c8e7dbb..68dc86ac04 100644 --- a/samples/Hackbook/Hackbook.xcodeproj/project.pbxproj +++ b/samples/Hackbook/Hackbook.xcodeproj/project.pbxproj @@ -31,6 +31,7 @@ 85AFB4E6158F9C5B000AF7F5 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 85AFB4E2158F9C5B000AF7F5 /* Icon.png */; }; 85AFB4E7158F9C5B000AF7F5 /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 85AFB4E3158F9C5B000AF7F5 /* Icon@2x.png */; }; 85C69D561602AFD4008AD9A0 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69D551602AFD4008AD9A0 /* Default-568h@2x.png */; }; + B9A4168016113EC3001E7A77 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9A4167F16113EC3001E7A77 /* AdSupport.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; DD35C4BE15B9307600C0849B /* FBConnect.bundle in Resources */ = {isa = PBXBuildFile; fileRef = DD35C4BD15B9307600C0849B /* FBConnect.bundle */; }; DD37EA8F15ABA4920015966B /* FacebookSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD37EA8E15ABA4920015966B /* FacebookSDK.framework */; }; /* End PBXBuildFile section */ @@ -68,6 +69,7 @@ 85AFB4E2158F9C5B000AF7F5 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = ""; }; 85AFB4E3158F9C5B000AF7F5 /* Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon@2x.png"; sourceTree = ""; }; 85C69D551602AFD4008AD9A0 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; + B9A4167F16113EC3001E7A77 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; }; DD35C4BD15B9307600C0849B /* FBConnect.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = FBConnect.bundle; path = Hackbook/FBConnect.bundle; sourceTree = ""; }; DD37EA8E15ABA4920015966B /* FacebookSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FacebookSDK.framework; path = ../../build/FacebookSDK.framework; sourceTree = ""; }; DD37EA9815ABA8A90015966B /* Facebook.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Facebook.h; path = ../../build/FacebookSDK.framework/Versions/A/DeprecatedHeaders/Facebook.h; sourceTree = ""; }; @@ -98,6 +100,7 @@ buildActionMask = 2147483647; files = ( 85A928C016114663008699F1 /* Social.framework in Frameworks */, + B9A4168016113EC3001E7A77 /* AdSupport.framework in Frameworks */, 84750AA0160A259400C1A13D /* Accounts.framework in Frameworks */, 30EA73FC13F5D590003DC0D2 /* CoreLocation.framework in Frameworks */, 30EA735E13F5D21B003DC0D2 /* UIKit.framework in Frameworks */, @@ -140,6 +143,7 @@ 30EA735C13F5D21B003DC0D2 /* Frameworks */ = { isa = PBXGroup; children = ( + B9A4167F16113EC3001E7A77 /* AdSupport.framework */, 84750A9F160A259400C1A13D /* Accounts.framework */, DD37EA8E15ABA4920015966B /* FacebookSDK.framework */, 30EA73FB13F5D590003DC0D2 /* CoreLocation.framework */, diff --git a/samples/HelloFacebookSample/HelloFacebookSample.xcodeproj/project.pbxproj b/samples/HelloFacebookSample/HelloFacebookSample.xcodeproj/project.pbxproj index 51449a79e3..9bfccae897 100644 --- a/samples/HelloFacebookSample/HelloFacebookSample.xcodeproj/project.pbxproj +++ b/samples/HelloFacebookSample/HelloFacebookSample.xcodeproj/project.pbxproj @@ -26,6 +26,7 @@ 85C69D8F1602B0D3008AD9A0 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69D8C1602B0D3008AD9A0 /* Default-568h@2x.png */; }; 85C69D901602B0D3008AD9A0 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69D8D1602B0D3008AD9A0 /* Default.png */; }; 85C69D911602B0D3008AD9A0 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69D8E1602B0D3008AD9A0 /* Default@2x.png */; }; + B9A4168716113ED6001E7A77 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9A4168616113ED6001E7A77 /* AdSupport.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; DD37EAC015ABA8FA0015966B /* FacebookSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD37EABF15ABA8FA0015966B /* FacebookSDK.framework */; }; DD37EAC315ABA8FE0015966B /* FacebookSDKResources.bundle in Resources */ = {isa = PBXBuildFile; fileRef = DD37EAC215ABA8FE0015966B /* FacebookSDKResources.bundle */; }; /* End PBXBuildFile section */ @@ -55,6 +56,7 @@ 85C69D8C1602B0D3008AD9A0 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 85C69D8D1602B0D3008AD9A0 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 85C69D8E1602B0D3008AD9A0 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; + B9A4168616113ED6001E7A77 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; }; DD37EABF15ABA8FA0015966B /* FacebookSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FacebookSDK.framework; path = ../../build/FacebookSDK.framework; sourceTree = ""; }; DD37EAC215ABA8FE0015966B /* FacebookSDKResources.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = FacebookSDKResources.bundle; path = ../../build/FacebookSDK.framework/Versions/A/Resources/FacebookSDKResources.bundle; sourceTree = ""; }; /* End PBXFileReference section */ @@ -65,6 +67,7 @@ buildActionMask = 2147483647; files = ( 85A928A31611305A008699F1 /* Social.framework in Frameworks */, + B9A4168716113ED6001E7A77 /* AdSupport.framework in Frameworks */, 8458462715A63635008A1F16 /* Accounts.framework in Frameworks */, 5F6AF18E1532A37B00DDBD75 /* UIKit.framework in Frameworks */, 5F6AF1901532A37B00DDBD75 /* Foundation.framework in Frameworks */, @@ -98,6 +101,7 @@ 5F6AF18C1532A37B00DDBD75 /* Frameworks */ = { isa = PBXGroup; children = ( + B9A4168616113ED6001E7A77 /* AdSupport.framework */, 5FC4959715C21151007EE54E /* CoreLocation.framework */, DD37EAC215ABA8FE0015966B /* FacebookSDKResources.bundle */, DD37EABF15ABA8FA0015966B /* FacebookSDK.framework */, diff --git a/samples/JustRequestSample/JustRequestSample.xcodeproj/project.pbxproj b/samples/JustRequestSample/JustRequestSample.xcodeproj/project.pbxproj index 2c3b94c8bd..6569fc9650 100644 --- a/samples/JustRequestSample/JustRequestSample.xcodeproj/project.pbxproj +++ b/samples/JustRequestSample/JustRequestSample.xcodeproj/project.pbxproj @@ -16,6 +16,7 @@ 85C69D691602B06E008AD9A0 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69D661602B06E008AD9A0 /* Default-568h@2x.png */; }; 85C69D6A1602B06E008AD9A0 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69D671602B06E008AD9A0 /* Default.png */; }; 85C69D6B1602B06E008AD9A0 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69D681602B06E008AD9A0 /* Default@2x.png */; }; + B9A4168E16113EE7001E7A77 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9A4168D16113EE7001E7A77 /* AdSupport.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; DDA290AD15ABA96200F533F9 /* FacebookSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DDA290AC15ABA96200F533F9 /* FacebookSDK.framework */; }; E2511742152BB6FE00CB342A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E2511741152BB6FE00CB342A /* UIKit.framework */; }; E2511744152BB6FE00CB342A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E2511743152BB6FE00CB342A /* Foundation.framework */; }; @@ -38,6 +39,7 @@ 85C69D661602B06E008AD9A0 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 85C69D671602B06E008AD9A0 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 85C69D681602B06E008AD9A0 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; + B9A4168D16113EE7001E7A77 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; }; DDA290AC15ABA96200F533F9 /* FacebookSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FacebookSDK.framework; path = ../../build/FacebookSDK.framework; sourceTree = ""; }; E251173D152BB6FE00CB342A /* JustRequestSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JustRequestSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; E2511741152BB6FE00CB342A /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; @@ -61,6 +63,7 @@ buildActionMask = 2147483647; files = ( 85A928CE161146AC008699F1 /* Social.framework in Frameworks */, + B9A4168E16113EE7001E7A77 /* AdSupport.framework in Frameworks */, 84605AB015A77B8600197AA7 /* Accounts.framework in Frameworks */, E2511742152BB6FE00CB342A /* UIKit.framework in Frameworks */, E2511744152BB6FE00CB342A /* Foundation.framework in Frameworks */, @@ -93,6 +96,7 @@ E2511740152BB6FE00CB342A /* Frameworks */ = { isa = PBXGroup; children = ( + B9A4168D16113EE7001E7A77 /* AdSupport.framework */, DDA290AC15ABA96200F533F9 /* FacebookSDK.framework */, 84605AAF15A77B8600197AA7 /* Accounts.framework */, E2511741152BB6FE00CB342A /* UIKit.framework */, diff --git a/samples/PlacePickerSample/PlacePickerSample.xcodeproj/project.pbxproj b/samples/PlacePickerSample/PlacePickerSample.xcodeproj/project.pbxproj index b7244b2de8..9b8c4260fe 100644 --- a/samples/PlacePickerSample/PlacePickerSample.xcodeproj/project.pbxproj +++ b/samples/PlacePickerSample/PlacePickerSample.xcodeproj/project.pbxproj @@ -16,6 +16,7 @@ 85C69D9E1602B105008AD9A0 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69D9B1602B105008AD9A0 /* Default-568h@2x.png */; }; 85C69D9F1602B105008AD9A0 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69D9C1602B105008AD9A0 /* Default.png */; }; 85C69DA01602B105008AD9A0 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69D9D1602B105008AD9A0 /* Default@2x.png */; }; + B9A4169516113EF8001E7A77 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9A4169416113EF8001E7A77 /* AdSupport.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; B9AF4BA9152E43EE00E9BA6C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9AF4BA8152E43EE00E9BA6C /* UIKit.framework */; }; B9AF4BAB152E43EE00E9BA6C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9AF4BAA152E43EE00E9BA6C /* Foundation.framework */; }; B9AF4BAD152E43EE00E9BA6C /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9AF4BAC152E43EE00E9BA6C /* CoreGraphics.framework */; }; @@ -40,6 +41,7 @@ 85C69D9B1602B105008AD9A0 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 85C69D9C1602B105008AD9A0 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 85C69D9D1602B105008AD9A0 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; + B9A4169416113EF8001E7A77 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; }; B9AF4BA4152E43EE00E9BA6C /* PlacePickerSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PlacePickerSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; B9AF4BA8152E43EE00E9BA6C /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; B9AF4BAA152E43EE00E9BA6C /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -65,6 +67,7 @@ buildActionMask = 2147483647; files = ( 85A928D5161146C7008699F1 /* Social.framework in Frameworks */, + B9A4169516113EF8001E7A77 /* AdSupport.framework in Frameworks */, 84605AAA15A777A800197AA7 /* Accounts.framework in Frameworks */, B9AF4C37152E449300E9BA6C /* CoreLocation.framework in Frameworks */, B9AF4BA9152E43EE00E9BA6C /* UIKit.framework in Frameworks */, @@ -98,6 +101,7 @@ B9AF4BA7152E43EE00E9BA6C /* Frameworks */ = { isa = PBXGroup; children = ( + B9A4169416113EF8001E7A77 /* AdSupport.framework */, DD37EA7715ABA3E70015966B /* FacebookSDK.framework */, DD37EA7515ABA3DF0015966B /* FacebookSDKResources.bundle */, 84605AA915A777A800197AA7 /* Accounts.framework */, diff --git a/samples/ProfilePictureSample/ProfilePictureSample.xcodeproj/project.pbxproj b/samples/ProfilePictureSample/ProfilePictureSample.xcodeproj/project.pbxproj index d027610480..e6fba7c3b1 100644 --- a/samples/ProfilePictureSample/ProfilePictureSample.xcodeproj/project.pbxproj +++ b/samples/ProfilePictureSample/ProfilePictureSample.xcodeproj/project.pbxproj @@ -25,6 +25,7 @@ B98686D0151D0B3700616412 /* PPViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B98686CF151D0B3700616412 /* PPViewController.m */; }; B98686D3151D0B3700616412 /* PPViewController_iPhone.xib in Resources */ = {isa = PBXBuildFile; fileRef = B98686D1151D0B3700616412 /* PPViewController_iPhone.xib */; }; B98686D6151D0B3700616412 /* PPViewController_iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = B98686D4151D0B3700616412 /* PPViewController_iPad.xib */; }; + B9A4169C16113F0A001E7A77 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9A4169B16113F0A001E7A77 /* AdSupport.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; DD37EA6D15ABA39D0015966B /* FacebookSDKResources.bundle in Resources */ = {isa = PBXBuildFile; fileRef = DD37EA6C15ABA39D0015966B /* FacebookSDKResources.bundle */; }; DD37EA6F15ABA3AC0015966B /* FacebookSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD37EA6E15ABA3AC0015966B /* FacebookSDK.framework */; }; /* End PBXBuildFile section */ @@ -53,6 +54,7 @@ B98686CF151D0B3700616412 /* PPViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PPViewController.m; sourceTree = ""; }; B98686D2151D0B3700616412 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/PPViewController_iPhone.xib; sourceTree = ""; }; B98686D5151D0B3700616412 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/PPViewController_iPad.xib; sourceTree = ""; }; + B9A4169B16113F0A001E7A77 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; }; DD37EA6C15ABA39D0015966B /* FacebookSDKResources.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = FacebookSDKResources.bundle; path = ../../build/FacebookSDK.framework/Versions/A/Resources/FacebookSDKResources.bundle; sourceTree = ""; }; DD37EA6E15ABA3AC0015966B /* FacebookSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FacebookSDK.framework; path = ../../build/FacebookSDK.framework; sourceTree = ""; }; /* End PBXFileReference section */ @@ -63,6 +65,7 @@ buildActionMask = 2147483647; files = ( 85A928DC161146E2008699F1 /* Social.framework in Frameworks */, + B9A4169C16113F0A001E7A77 /* AdSupport.framework in Frameworks */, 847BBEAA160B88E8004EC7CB /* Accounts.framework in Frameworks */, B98686BD151D0B3700616412 /* UIKit.framework in Frameworks */, B98686BF151D0B3700616412 /* Foundation.framework in Frameworks */, @@ -96,6 +99,7 @@ B98686BB151D0B3700616412 /* Frameworks */ = { isa = PBXGroup; children = ( + B9A4169B16113F0A001E7A77 /* AdSupport.framework */, DD37EA6E15ABA3AC0015966B /* FacebookSDK.framework */, DD37EA6C15ABA39D0015966B /* FacebookSDKResources.bundle */, B98686BC151D0B3700616412 /* UIKit.framework */, diff --git a/samples/Scrumptious/Scrumptious.xcodeproj/project.pbxproj b/samples/Scrumptious/Scrumptious.xcodeproj/project.pbxproj index 535dc40dd6..876c894c53 100644 --- a/samples/Scrumptious/Scrumptious.xcodeproj/project.pbxproj +++ b/samples/Scrumptious/Scrumptious.xcodeproj/project.pbxproj @@ -22,6 +22,7 @@ 85C69DCA1602B411008AD9A0 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69DC71602B411008AD9A0 /* Default-568h@2x.png */; }; 85C69DCB1602B411008AD9A0 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69DC81602B411008AD9A0 /* Default.png */; }; 85C69DCC1602B411008AD9A0 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69DC91602B411008AD9A0 /* Default@2x.png */; }; + B9A416A316113F1C001E7A77 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9A416A216113F1C001E7A77 /* AdSupport.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; B9C1C35915129F0E008FA5D1 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9C1C35815129F0E008FA5D1 /* CoreLocation.framework */; }; B9CD0A74150EA4DD00560A93 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9CD0A73150EA4DD00560A93 /* UIKit.framework */; }; B9CD0A76150EA4DD00560A93 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9CD0A75150EA4DD00560A93 /* Foundation.framework */; }; @@ -58,6 +59,7 @@ 85C69DC71602B411008AD9A0 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "scrumptious/Default-568h@2x.png"; sourceTree = SOURCE_ROOT; }; 85C69DC81602B411008AD9A0 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Default.png; path = scrumptious/Default.png; sourceTree = SOURCE_ROOT; }; 85C69DC91602B411008AD9A0 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default@2x.png"; path = "scrumptious/Default@2x.png"; sourceTree = SOURCE_ROOT; }; + B9A416A216113F1C001E7A77 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; }; B9C1C35815129F0E008FA5D1 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; B9CD0A6F150EA4DD00560A93 /* Scrumptious.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Scrumptious.app; sourceTree = BUILT_PRODUCTS_DIR; }; B9CD0A73150EA4DD00560A93 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; @@ -89,6 +91,7 @@ buildActionMask = 2147483647; files = ( 85A928E316114706008699F1 /* Social.framework in Frameworks */, + B9A416A316113F1C001E7A77 /* AdSupport.framework in Frameworks */, 84A5DA9615A68A3D00FE54AF /* Accounts.framework in Frameworks */, B9C1C35915129F0E008FA5D1 /* CoreLocation.framework in Frameworks */, B9CD0A74150EA4DD00560A93 /* UIKit.framework in Frameworks */, @@ -123,6 +126,7 @@ B9CD0A72150EA4DD00560A93 /* Frameworks */ = { isa = PBXGroup; children = ( + B9A416A216113F1C001E7A77 /* AdSupport.framework */, 8534B4DE15CC657900348ED2 /* FBUserSettingsViewResources.bundle */, DD55EAB015ABA246000A64B8 /* FacebookSDKResources.bundle */, DD55EAAE15AB9EDF000A64B8 /* FacebookSDK.framework */, diff --git a/samples/SessionLoginSample/SessionLoginSample.xcodeproj/project.pbxproj b/samples/SessionLoginSample/SessionLoginSample.xcodeproj/project.pbxproj index 0c83eba60c..d5e47ab1a3 100644 --- a/samples/SessionLoginSample/SessionLoginSample.xcodeproj/project.pbxproj +++ b/samples/SessionLoginSample/SessionLoginSample.xcodeproj/project.pbxproj @@ -25,6 +25,7 @@ 85C69DB41602B33C008AD9A0 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69DB11602B33C008AD9A0 /* Default-568h@2x.png */; }; 85C69DB51602B33C008AD9A0 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69DB21602B33C008AD9A0 /* Default.png */; }; 85C69DB61602B33C008AD9A0 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69DB31602B33C008AD9A0 /* Default@2x.png */; }; + B9A416AA16113F2D001E7A77 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9A416A916113F2D001E7A77 /* AdSupport.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; DDA290A415ABA93700F533F9 /* FacebookSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DDA290A315ABA93700F533F9 /* FacebookSDK.framework */; }; /* End PBXBuildFile section */ @@ -52,6 +53,7 @@ 85C69DB11602B33C008AD9A0 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 85C69DB21602B33C008AD9A0 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 85C69DB31602B33C008AD9A0 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; + B9A416A916113F2D001E7A77 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; }; DDA290A315ABA93700F533F9 /* FacebookSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FacebookSDK.framework; path = ../../build/FacebookSDK.framework; sourceTree = ""; }; /* End PBXFileReference section */ @@ -61,6 +63,7 @@ buildActionMask = 2147483647; files = ( 85A928EA1611471C008699F1 /* Social.framework in Frameworks */, + B9A416AA16113F2D001E7A77 /* AdSupport.framework in Frameworks */, 84A5DA9E15A68D1500FE54AF /* Accounts.framework in Frameworks */, 84C757BD152A38770070DD9C /* UIKit.framework in Frameworks */, 84C757BF152A38770070DD9C /* Foundation.framework in Frameworks */, @@ -93,6 +96,7 @@ 84C757BB152A38770070DD9C /* Frameworks */ = { isa = PBXGroup; children = ( + B9A416A916113F2D001E7A77 /* AdSupport.framework */, DDA290A315ABA93700F533F9 /* FacebookSDK.framework */, 84A5DA9D15A68D1500FE54AF /* Accounts.framework */, 84C757BC152A38770070DD9C /* UIKit.framework */, diff --git a/samples/SwitchUserSample/SwitchUserSample.xcodeproj/project.pbxproj b/samples/SwitchUserSample/SwitchUserSample.xcodeproj/project.pbxproj index d820a700f5..69271aec10 100644 --- a/samples/SwitchUserSample/SwitchUserSample.xcodeproj/project.pbxproj +++ b/samples/SwitchUserSample/SwitchUserSample.xcodeproj/project.pbxproj @@ -34,6 +34,7 @@ 85C69DC11602B393008AD9A0 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 85C69DBE1602B393008AD9A0 /* Default@2x.png */; }; 85D0ED8C1538A9F400D88664 /* SUProfileTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 85D0ED8B1538A9F400D88664 /* SUProfileTableViewCell.m */; }; 85D0ED8F1538BF6200D88664 /* SUUserManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 85D0ED8E1538BF6200D88664 /* SUUserManager.m */; }; + B9A416B116113F3E001E7A77 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9A416B016113F3E001E7A77 /* AdSupport.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; DD37EA6515ABA33D0015966B /* FacebookSDKResources.bundle in Resources */ = {isa = PBXBuildFile; fileRef = DD37EA6415ABA33D0015966B /* FacebookSDKResources.bundle */; }; DD55EAA515AB9D1A000A64B8 /* FacebookSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD55EAA415AB9D1A000A64B8 /* FacebookSDK.framework */; }; /* End PBXBuildFile section */ @@ -74,6 +75,7 @@ 85D0ED8B1538A9F400D88664 /* SUProfileTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUProfileTableViewCell.m; sourceTree = ""; }; 85D0ED8D1538BF6200D88664 /* SUUserManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUserManager.h; sourceTree = ""; }; 85D0ED8E1538BF6200D88664 /* SUUserManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUserManager.m; sourceTree = ""; }; + B9A416B016113F3E001E7A77 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; }; DD37EA6415ABA33D0015966B /* FacebookSDKResources.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = FacebookSDKResources.bundle; path = ../../build/FacebookSDK.framework/Versions/A/Resources/FacebookSDKResources.bundle; sourceTree = ""; }; DD55EAA415AB9D1A000A64B8 /* FacebookSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FacebookSDK.framework; path = ../../build/FacebookSDK.framework; sourceTree = ""; }; /* End PBXFileReference section */ @@ -84,6 +86,7 @@ buildActionMask = 2147483647; files = ( 85A928F116114738008699F1 /* Social.framework in Frameworks */, + B9A416B116113F3E001E7A77 /* AdSupport.framework in Frameworks */, 84605AAD15A77AFB00197AA7 /* Accounts.framework in Frameworks */, 856DB04E153393C3006F6A33 /* UIKit.framework in Frameworks */, 856DB050153393C3006F6A33 /* Foundation.framework in Frameworks */, @@ -116,6 +119,7 @@ 856DB04C153393C3006F6A33 /* Frameworks */ = { isa = PBXGroup; children = ( + B9A416B016113F3E001E7A77 /* AdSupport.framework */, DD37EA6415ABA33D0015966B /* FacebookSDKResources.bundle */, DD55EAA415AB9D1A000A64B8 /* FacebookSDK.framework */, 84605AAC15A77AFB00197AA7 /* Accounts.framework */, diff --git a/src/FBRequest.m b/src/FBRequest.m index 5e5da9b2e2..a7f2700e26 100644 --- a/src/FBRequest.m +++ b/src/FBRequest.m @@ -76,7 +76,7 @@ - (id)initWithSession:(FBSession*)session graphPath:nil // but assuring a nil graphPath for the rest case parameters:parameters HTTPMethod:HTTPMethod]; - if (self = [super init]) { + if (self) { self.restMethod = restMethod; } return self; diff --git a/src/FBSettings.m b/src/FBSettings.m index 2414d9974a..e86a0ac226 100644 --- a/src/FBSettings.m +++ b/src/FBSettings.m @@ -19,6 +19,7 @@ #import "FBSettings.h" #import "FBSettings+Internal.h" +#import #import NSString *const FBLoggingBehaviorFBRequests = @"fb_requests"; @@ -63,13 +64,9 @@ + (void)setShouldAutoPublishInstall:(BOOL)newValue { + (void)autoPublishInstall:(NSString *)appID { if ([FBSettings shouldAutoPublishInstall]) { dispatch_once(&g_publishInstallOnceToken, ^{ - @try { - // dispatch_once is great, but not re-entrant. Inside publishInstall we use FBRequest, which will - // cause this function to get invoked a second time. By scheduling the work, we can sidestep the problem. - [[FBSettings class] performSelector:@selector(publishInstall:) withObject:appID afterDelay:FBPublishDelay]; - } @catch (NSException *exception) { - NSLog(@"Failure during autoPublishInstall: %@", exception.reason); - } + // dispatch_once is great, but not re-entrant. Inside publishInstall we use FBRequest, which will + // cause this function to get invoked a second time. By scheduling the work, we can sidestep the problem. + [[FBSettings class] performSelector:@selector(publishInstall:) withObject:appID afterDelay:FBPublishDelay]; }); } } @@ -79,60 +76,84 @@ + (void)autoPublishInstall:(NSString *)appID { #pragma mark proto-activity publishing code + (void)publishInstall:(NSString *)appID { - if (!appID) { - appID = [FBSession defaultAppID]; - } - - if (!appID) { - // if the appID is still nil, exit early. - return; - } - - // look for a previous ping & grab the facebook app's current attribution id. - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSString *pingKey = [NSString stringWithFormat:FBLastAttributionPing, appID, nil]; - NSDate *lastPing = [defaults objectForKey:pingKey]; - NSString *attributionID = [[UIPasteboard pasteboardWithName:FBAttributionPasteboard create:NO] string]; - - if (attributionID && !lastPing) { - FBRequestHandler publishCompletionBlock = ^(FBRequestConnection *connection, - id result, - NSError *error) { - if (!error) { - // if server communication was successful, take note of the current time. - [defaults setObject:[NSDate date] forKey:pingKey]; - [defaults synchronize]; - } else { - // there was a problem. allow a repeat execution. - g_publishInstallOnceToken = 0; - } - }; - - FBRequestHandler pingCompletionBlock = ^(FBRequestConnection *connection, - id result, - NSError *error) { - if (!error) { - if ([result respondsToSelector:@selector(objectForKey:)] && - [[result objectForKey:FBSupportsAttribution] boolValue]) { - // set up the HTTP POST to publish the attribution ID. - NSString *publishPath = [NSString stringWithFormat:FBPublishActivityPath, appID, nil]; - NSMutableDictionary *installActivity = [FBGraphObject graphObject]; - [installActivity setObject:FBMobileInstallEvent forKey:@"event"]; - [installActivity setObject:attributionID forKey:@"attribution"]; - - FBRequest *publishRequest = [[[FBRequest alloc] initForPostWithSession:nil graphPath:publishPath graphObject:installActivity] autorelease]; - [publishRequest startWithCompletionHandler:publishCompletionBlock]; - } else { - // the app has turned off install insights. prevent future attempts. - [defaults setObject:[NSDate date] forKey:pingKey]; - [defaults synchronize]; + @try { + if (!appID) { + appID = [FBSession defaultAppID]; + } + + if (!appID) { + // if the appID is still nil, exit early. + return; + } + + // look for a previous ping & grab the facebook app's current attribution id. + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSString *pingKey = [NSString stringWithFormat:FBLastAttributionPing, appID, nil]; + NSDate *lastPing = [defaults objectForKey:pingKey]; + NSString *attributionID = [[UIPasteboard pasteboardWithName:FBAttributionPasteboard create:NO] string]; + + NSString *advertiserID = nil; + if ([ASIdentifierManager class]) { + ASIdentifierManager *manager = [ASIdentifierManager sharedManager]; + advertiserID = [[manager advertisingIdentifier] UUIDString]; + } + + if ((attributionID || advertiserID) && !lastPing) { + FBRequestHandler publishCompletionBlock = ^(FBRequestConnection *connection, + id result, + NSError *error) { + @try { + if (!error) { + // if server communication was successful, take note of the current time. + [defaults setObject:[NSDate date] forKey:pingKey]; + [defaults synchronize]; + } else { + // there was a problem. allow a repeat execution. + g_publishInstallOnceToken = 0; + } + } @catch (NSException *ex1) { + NSLog(@"Failure after install publish: %@", ex1.reason); } - } - }; - - NSString *pingPath = [NSString stringWithFormat:FBSupportsAttributionPath, appID, nil]; - FBRequest *pingRequest = [[[FBRequest alloc] initWithSession:nil graphPath:pingPath] autorelease]; - [pingRequest startWithCompletionHandler:pingCompletionBlock]; + }; + + FBRequestHandler pingCompletionBlock = ^(FBRequestConnection *connection, + id result, + NSError *error) { + if (!error) { + @try { + if ([result respondsToSelector:@selector(objectForKey:)] && + [[result objectForKey:FBSupportsAttribution] boolValue]) { + // set up the HTTP POST to publish the attribution ID. + NSString *publishPath = [NSString stringWithFormat:FBPublishActivityPath, appID, nil]; + NSMutableDictionary *installActivity = [FBGraphObject graphObject]; + [installActivity setObject:FBMobileInstallEvent forKey:@"event"]; + + if (attributionID) { + [installActivity setObject:attributionID forKey:@"attribution"]; + } + if (advertiserID) { + [installActivity setObject:advertiserID forKey:@"advertiser_id"]; + } + + FBRequest *publishRequest = [[[FBRequest alloc] initForPostWithSession:nil graphPath:publishPath graphObject:installActivity] autorelease]; + [publishRequest startWithCompletionHandler:publishCompletionBlock]; + } else { + // the app has turned off install insights. prevent future attempts. + [defaults setObject:[NSDate date] forKey:pingKey]; + [defaults synchronize]; + } + } @catch (NSException *ex2) { + NSLog(@"Failure during install publish: %@", ex2.reason); + } + } + }; + + NSString *pingPath = [NSString stringWithFormat:FBSupportsAttributionPath, appID, nil]; + FBRequest *pingRequest = [[[FBRequest alloc] initWithSession:nil graphPath:pingPath] autorelease]; + [pingRequest startWithCompletionHandler:pingCompletionBlock]; + } + } @catch (NSException *ex3) { + NSLog(@"Failure before/during install ping: %@", ex3.reason); } } diff --git a/src/facebook-ios-sdk.xcodeproj/project.pbxproj b/src/facebook-ios-sdk.xcodeproj/project.pbxproj index 90a07099da..dafa75eff6 100644 --- a/src/facebook-ios-sdk.xcodeproj/project.pbxproj +++ b/src/facebook-ios-sdk.xcodeproj/project.pbxproj @@ -123,6 +123,8 @@ B966ADFC152D020E005FC07B /* FBGraphObjectTableCell.h in Headers */ = {isa = PBXBuildFile; fileRef = B966ADFA152D020E005FC07B /* FBGraphObjectTableCell.h */; }; B966ADFD152D020E005FC07B /* FBGraphObjectTableCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B966ADFB152D020E005FC07B /* FBGraphObjectTableCell.m */; }; B96F15E3152B927E00A52896 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B96F15E2152B927E00A52896 /* CoreLocation.framework */; }; + B9A4166A16113DE3001E7A77 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9A4166916113DE3001E7A77 /* AdSupport.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; + B9A4166C16113DF4001E7A77 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9A4166916113DE3001E7A77 /* AdSupport.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; B9C6E1341525219600E46808 /* FBCacheIndex.h in Headers */ = {isa = PBXBuildFile; fileRef = B9C6E1301525219600E46808 /* FBCacheIndex.h */; }; B9C6E1351525219600E46808 /* FBCacheIndex.m in Sources */ = {isa = PBXBuildFile; fileRef = B9C6E1311525219600E46808 /* FBCacheIndex.m */; }; B9C6E1371525219600E46808 /* FBDataDiskCache.m in Sources */ = {isa = PBXBuildFile; fileRef = B9C6E1331525219600E46808 /* FBDataDiskCache.m */; }; @@ -263,6 +265,7 @@ B966ADFA152D020E005FC07B /* FBGraphObjectTableCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBGraphObjectTableCell.h; sourceTree = ""; }; B966ADFB152D020E005FC07B /* FBGraphObjectTableCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBGraphObjectTableCell.m; sourceTree = ""; }; B96F15E2152B927E00A52896 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; + B9A4166916113DE3001E7A77 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; }; B9C6E1301525219600E46808 /* FBCacheIndex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBCacheIndex.h; sourceTree = ""; }; B9C6E1311525219600E46808 /* FBCacheIndex.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBCacheIndex.m; sourceTree = ""; }; B9C6E1331525219600E46808 /* FBDataDiskCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBDataDiskCache.m; sourceTree = ""; }; @@ -309,6 +312,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + B9A4166C16113DF4001E7A77 /* AdSupport.framework in Frameworks */, 85A928991611272D008699F1 /* Social.framework in Frameworks */, 845857A216096ED000CC89E5 /* Accounts.framework in Frameworks */, 84B5F11C1552FD3C00A55DDC /* CoreGraphics.framework in Frameworks */, @@ -325,6 +329,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + B9A4166A16113DE3001E7A77 /* AdSupport.framework in Frameworks */, B96F15E3152B927E00A52896 /* CoreLocation.framework in Frameworks */, 8446FDB4151D2674000BE007 /* UIKit.framework in Frameworks */, B9CC137315266B9000443948 /* QuartzCore.framework in Frameworks */, @@ -361,6 +366,7 @@ isa = PBXGroup; children = ( 85A928981611272D008699F1 /* Social.framework */, + B9A4166916113DE3001E7A77 /* AdSupport.framework */, 845857A116096ED000CC89E5 /* Accounts.framework */, 85A928981611272D008699F1 /* Social.framework */, B9CC137215266B9000443948 /* QuartzCore.framework */,