How to get Facebook attribution ID on iOS? - ios

Facebook attribution ID is available if user installed Facebook app on his phone.
On Android, it can be extracted with this piece of code -
Report Android app install back to facebook without using their api
By looking at Facebook's SDK for iOS, they access it with -
+ (NSString *)attributionID {
return [[UIPasteboard pasteboardWithName:#"fb_app_attribution" create:NO] string];
}
(https://github.com/facebook/facebook-ios-sdk/blob/master/src/FBUtility.m)
But when I call this method on a phone with FB app installed, it returns nil.
How do I extract it on iOS?

Unfortunately I think the answer is that you can't do this. At least for as long as Facebook is using the UIPasteboard.
That code in your post would access an app-specific pasteboard. If it was created by the Facebook application then it would only be accessible to Facebook's other applications.
The UIPasteboard class enables an app to share data within the app and
with another app. To share data with any other app, you can use
system-wide pasteboards; to share data with another app that has the
same team ID as your app, you can use app-specific pasteboards.
The quote above is from the docs

Related

What are all the custom URL schemes supported by the Workplace by Facebook iPhone app?

I am trying to open a group page in Workplace by Facebook app, unfortunately I did not find any custom URL scheme to do it like for the Facebook app.
Does anyone have more information about the custom url schema that can be sent to the Workplace by Facebook app for iPhone?
I recently had the same issue and found out that the main url scheme for Workplace is fbatwork.
To open the app straight to a group, the only working format on iOS seems to be
fbatwork://group?id=your-group-id
There are also a few more available, but I don't know exactly what's their purpose: fbatworksso, fbatworksignup, fbatworkssoreauth, fb-work-emailless

How to open an iOS Application from Facebook,Twitter and Google+ posts which are shared from the iOS application using UIActivityViewController?

I have shared few posts to Facebook,Google+ and Twitter from my iOS application.How can I open my app when users click on those posts I have shared?I have used UIActivityViewController for sharing.
For Facebook you should use app links: https://developers.facebook.com/docs/applinks/ios. You can host links to your app with their hosting - https://developers.facebook.com/quickstarts/?platform=app-links-host
For Twitter you should use https://dev.twitter.com/cards/mobile/deep-linking but need the server side(hosting) with tags for link. Also, with default UIActivityViewController you cant do this.

iOS: Detect whether my SDK is installed on another apps on the device

I am developing a location based Q&A SDK for mobile devices.
When a question is asked about a specific location, the server side targets the most relevant user and sends the question to that user. If the user fails to answer, the question is sent to the second best user, and so on.
The problem is that my SDK might be installed on more than one application on the device, meaning that the user can get a question more than once.
Is there a way to detect whether my SDK is installed on more than one app? I thought that sending the UDID to the server might work, but iOS UDIDs differ between applications.
You can use UIPasteboard to share data between applications on the device.
The UIPasteboard class enables an app to share data within the app and with another app. To share data with any other app, you can use system-wide pasteboards; to share data with another app that has the same team ID as your app, you can use app-specific pasteboards.
In your SDK, do something like this:
#interface SDKDetector : NSObject
#end
#implementation SDKDetector
+ (void)load
{
int numberOfApps = (int)[self numberOfAppsInDeviceUsingSDK];
NSLog(#"Number of apps using sdk:%d", numberOfApps);
}
+ (NSInteger)numberOfAppsInDeviceUsingSDK
{
static NSString *pasteboardType = #"mySDKPasteboardUniqueKey";
NSData *value = [[UIPasteboard generalPasteboard] valueForPasteboardType:pasteboardType];
NSMutableArray *storedData = [[NSKeyedUnarchiver unarchiveObjectWithData:value] mutableCopy];
if (!storedData) {
storedData = [NSMutableArray new];
}
NSString *bundleId = [[NSBundle mainBundle] bundleIdentifier];
if (![storedData containsObject:bundleId]) {
[storedData addObject:[[NSBundle mainBundle] bundleIdentifier]];
}
value = [NSKeyedArchiver archivedDataWithRootObject:storedData];
[[UIPasteboard generalPasteboard] setData:value forPasteboardType:pasteboardType];
return [storedData count];
}
#end
If you only want to provide an SDK, it is not possible. Apple has added security steps to prevent that for user privacy. Keychain sharing will not work, because apps must share the same bundle seed ID (see here for more info).
If you want to provide an app along with your SDK, then you could do something like Facebook does, where app sends a "helo" message, Facebook asks user and finally Facebook sends "ehlo" message.
Your App -> "I would like to use the SDK; please give me token" -> SDK Controller App -> (Remember which apps have requested use) -> "OK, you can use the SDK; here is a token: #123" -> Your App
The SDK controller app can now send the server the list of apps.
I think you can group the apps on the same device by IP address as they will use the same address to connect to your server.
So the IP address will represent the device and the API key will represent the app that uses the SDK.
Can you try using
advertisingIdentifier
Not sure whether it serves your purpose. It is explained in here ASIdentifierManager class reference : Apple doc
I think its possible using keychain, you can have an unique keychain key in which you can save anything you want, and can be accessed by other apps if available. So for your SDK, lets say if there is one app, it will register some value in keychain with a unique key which is private to your SDK only if the key doesn't exist, and if it exist you get to know, since you can save any value in keychain, you can try multiple options and combinations which suits you.
You can use KeychainItemWrapper for the implementations.
Elaboration
Lets say we have an method.
[MySDK register];
Which can be used anywhere, say in AppDelegate. The register method will generate a token for the app, for the device, which we will save in the keychain using an unique key we have defined in the SDK, say in com.mysdk.key. And while saving in keychain the SDK can actually do a registration.
We consider the above method is implemented in multiple apps.
Now we have scenario.
User installs an App-A which uses the SDK, the register method will call and create a token and will save in keychain for the first time.
Now user installs another App-B which also uses the SDK, the same register method will call, but now it will check for the key com.mysdk.key in keychain, if exist it will just update the count for the token, which meant for the device.
Note
Keychain not meant to save only unique identifier, you can save other informations too.
Update
Check demo projects https://db.tt/7xpKrgMp
The wrapper I have used in the projects is same as SDK in your case which is same in both the projects.
Cheers.

How to Show Tweet via [MyAppName] in Twitter when I tweet via SLComposeViewController iOS sdk

I have implemented to tweet by default ios sdk using SLComposeViewController ,
But In twitter , Its Shows via iOS by default,
How I can set my Appname, that it will show "via [MyAppName]" in twitter
I have already create app with same name of ios app in twitter and its only 5 character name,
My App is live on app store. Still It doesn't show via[My App name]
Please give feedback of any other suggestion or any idea you have.
I don't think you can do that using SLComposeViewController.
You'll need to have registered an "application" (AKA obtain an API key) on dev.twitter.com to use custom name in "via [MyAppName]" on Twitter.
After that, you can create your own custom view to post to Twitter.

Track Facebook app installs through ads

We are looking for a way to track if the current user comes from a Facebook ad. Is there a way to achieve that?
We need to set this info in our database in order to make queries on these people (cohorts).
I found some similar questions :
Here
And here.
We are not looking for external services, we need to have this info in our database to create cohorts.
P.S: We are already tracking installs with [FBSettings publishInstall:FACEBOOK_APP_ID];
While reverse engineering some Tracking frameworks I found that most of them are getting the Facebook Attribute ID (Advertiser ID) from the pasteboard. It seems that Facebook is setting that after the ad is touched.
I couldn't find any documentation but the Facebook SDK has a class FBUtility with an attributionID class method.
+ (NSString *)attributionID
{
return [[UIPasteboard pasteboardWithName:#"fb_app_attribution" create:NO] string];
}

Resources