Ok, so I've got a "completed" iOS phonegap/cordova project, using version 3.4 in xcode 5. I know I need to integrate the facebook sdk in order to track the installs for mobile ads.
Will simply integrating the sdk as per Facebook's instructions here https://developers.facebook.com/docs/ios/getting-started/ do the job, or do I need to use the entire facebook connect plugin as outlined here https://github.com/phonegap/phonegap-facebook-plugin being that I only need to track installs?
Also, when this is taken care of I need to add the following to the UIApplicationDelegate applicationDidBecomeActive selector
[FBSettings setDefaultAppID:YOUR_APP_ID];
[FBAppEvents activateApp];
Yet I can find no clear answer on exactly where I need to place this, (I have little to no knowledge of obj-c), where and in which file in my xcode project do I need to place this? I did find this out from a transcript of an open session on phonegap, it didn't help me much but may mean something to you:
Sometimes, some SDK or others ask us to add some lines in the objective-C, like Facebook for "Mobile App Install Ads" they ask to add "[FBSettings publishInstall:YOUR_APP_ID]" in UIApplicationDelegate applicationDidBecomeActive selector - but with phonegap project, we have not this method, so is there a equivalent in the code generated by phonegap? A: If you are developing locally using Xcode, you can access this method in the application delegate class. This is not available inside of the PhoneGap Build service.
Thanks for your help.
Having looked at this issue again, the answer is pretty simple.
Follow the instructions for creating an app and installing the SDK:
It tells you exactly how to do this for iOS here https://developers.facebook.com/docs/ios/getting-started/
Make sure to follow the instructions to the letter and that you add the relevant rows/values to your project's .plist file.
The final piece of information you'll need is understanding the import of the Facebook SDK header file into the AppDelegate.m file in your Xcode project and the applicationDidBecomeActive selector.
In your project's ApplicationDelegate.m file copy #import <FacebookSDK/FacebookSDK.h>
directly below your other import statements. Hint: they look similar and are near the top.
Now copy the following into your AppDelegate.m replacing the dummy app id @"123456789" with your facebook app id. Place this code directly above @end
in your AppDelegate.m file.
-(void)applicationDidBecomeActive:(UIApplication *)application
{
[FBSettings setDefaultAppID: @"123456789"];
[FBAppEvents activateApp];
}
That's it. Now you can try an install of your app onto your development device and check it's reporting correctly by visiting your app dashboard on Facebook, scrolling down to the bottom, or finding the section about latest installs.
It's done automatically by the javascript sdk:
https://developers.facebook.com/docs/reference/javascript/FB.AppEvents.LogEvent#examples
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