有没有办法检测用户是否真的按下了应用程序中的Twitter / Facebook帖子按钮?

时间:2015-02-08 22:10:56

标签: ios slcomposeviewcontroller

我想给予"奖励积分"对于在Facebook上发布我的广告消息或发布我的广告消息的用户。我怎样才能检测到......

1)用户实际按下了发布按钮(这样我可以在应用中给他们奖励积分)?

2)用户没有更改消息框中的任何文字(我的广告)?

在旁注中,是否可以为这些不可编辑的消息框设置?这是我的代码实际呈现消息以发布每个:

- (IBAction)tweetButtonPressed:(id)sender
{
    if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
    {
        SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
        [tweetSheet setInitialText:@"My advertisement message goes here."];
        [self presentViewController:tweetSheet animated:YES completion:nil];
    }

    else
    {
        UIAlertView *alertView = [[UIAlertView alloc]
                                  initWithTitle:@"Twitter Connection Failed"
                                  message:@"Make sure your device has an internet connection and you are connected to Twitter through your iPhone settings."
                                  delegate:self
                                  cancelButtonTitle:@"OK"
                                  otherButtonTitles:nil];
        [alertView show];
    }
}



- (IBAction)facebookPostButtonPressed:(id)sender
{
    if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
    {
        SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

        [controller setInitialText:@"My advertisement message goes here."];
        [self presentViewController:controller animated:YES completion:nil];
    }

    else
    {
        UIAlertView *alertView = [[UIAlertView alloc]
                                  initWithTitle:@"Facebook Connection Failed"
                                  message:@"Make sure your device has an internet connection and you are connected to Facebook through your iPhone settings."
                                  delegate:self
                                  cancelButtonTitle:@"OK"
                                  otherButtonTitles:nil];
        [alertView show];
    }
}

1 个答案:

答案 0 :(得分:1)

你可以使用compliton hander知道他是否按下了帖子按钮,但是你无法知道帖子的内容。 如果你真的想要自己实现facebook,甚至可以检查帖子的优点。 我这样说是因为当一个应用程序要求我发帖时,我总是把它作为"私人"所以没有人看到,但我仍然得到了#34; Bonus"。

Apple Docs

Possible values for the result parameter of the completionHandler property.

Declaration
OBJECTIVE-C
typedef NS_ENUM (NSInteger,
   SLComposeViewControllerResult ) {
   SLComposeViewControllerResultCancelled,
   SLComposeViewControllerResultDone 
 };
Constants
SLComposeViewControllerResultCancelled
The view controller is dismissed without sending the post. For example, the user selects Cancel or the account is not available.

Available in iOS 6.0 and later.

SLComposeViewControllerResultDone
The view controller is dismissed and the message is being sent in the background. This occurs when the user selects Done.

Available in iOS 6.0 and later.

https://developer.apple.com/library/ios/documentation/NetworkingInternet/Reference/SLComposeViewController_Class/#//apple_ref/c/tdef/SLComposeViewControllerResult