is there any way I can get some kind of feedback from the new FBLikeControl if the user liked the page? Or at least to know somehow, that he returned back to the app from the Facebook app?
Update:
Since Facebook apparently made this header private, you now have to subscribe directly to the notification using a raw string:
[[NSNotificationCenter defaultCenter] addObserver:myObject selector:@selector(myCallback:) name:@"FBLikeActionControllerDidUpdateNotification"];
Old answer for reference:
For anyone in the future looking for this: I ended up subscribing myself to FBLikeActionControllerDidUpdateNotification notifications. Once the notification is received you can do the following:
if ([notification.object isKindOfClass:[FBLikeActionController class]]) {
if ([(FBLikeActionController*)notification.object objectIsLiked]) {
// do your stuff here, user liked!
}
}
Because the FBLikeActionController.h is a private header, you can get around that by listening to notification string:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(facebookLikeNotification:) name:@"FBLikeActionControllerDidUpdateNotification" object:nil];
And handling the notification using selectors. I added lldb pragmas to suppress undefined selector warnings:
- (void)facebookLikeNotification:(NSNotification*)notification {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
SEL selector = @selector(objectIsLiked);
if (notification.object && [notification.object respondsToSelector:selector]) {
BOOL (*BOOLMsgSend)(id, SEL) = (typeof(BOOLMsgSend)) objc_msgSend;
BOOL isLiked = BOOLMsgSend(notification.object, selector);
DDLogDebug(@"is liked: %d",isLiked);
}
#pragma clang diagnostic pop
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With