-
Notifications
You must be signed in to change notification settings - Fork 8
Create Unique Landing Pages and Share with Facebook SDK Share Dialog
Shingo Hagiwara edited this page Aug 21, 2014
·
3 revisions
The AppSocially iOS SDK can be used to create unique landing pages for every user-user pair in an invitation event or individual landing pages for each sharing event. Having unique landing pages gives us the ability to track performance results separately for each different event, and to run A/B tests across different landing page designs with different embedded content for different users.
Below is an example of how to create a landing page with AppSocially's iOS createPageFrom:to:shareInfo:via:completionHandler:
method and then post that landing page to Facebook with the with Facebook iOS SDK.
// Create landing page for AppSocially Sharing event
// Requirements:
// kImageURL: String - the URL of an image to be embedded in the landing page like this
//{{data.kDataPropertyContentURL}}
// kPresetMessage: String - the Message of an image to be embedded in the landing page like this
//{{data.kDataPropertyMessage}}
//You can set any params shareInfo which you like
// facebook_id: String - Sender facebook user ID
// dummy_sendername: String - The display name of the current user
NSDictionary *shareInfo = @{kDataPropertyMessage: kPresetMessage,
kDataPropertyContentURL: kImageURL};
[ASSharer createPageFrom:@{@"id": @"facebook_id", @"name": @"dummy_sendername"}
to:nil
shareInfo:shareInfo
via:@"facebook"
completionHandler:^(NSDictionary *result, NSError *error) {
if (error) {
NSLog(@"error:%@", error);
return;
}
// Retrieve the URL of the landing page
NSDictionary *pageInfo = result[@"page"];
NSString *urlStr = pageInfo[@"url"];
// Share with the Facebook SDK's Share Dialog
FBAppCall *appCall = [FBDialogs presentShareDialogWithLink:[NSURL URLWithString:urlStr]
handler:
^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
NSLog(@"Error: %@", error.description);
}
else {
NSLog(@"Success!");
}
}];
if (!appCall) {
NSLog(@"The Facebook Share Dialog is not available.");
}
}];
ShareSample and shareWithFacebookSDK
method in the sample are useful for the reference.