Im trying to figure out how to determine the users iCloud status. I've read the developer reference outline and I still can't figure out how to determine this. Heres the code that I have extracted and tried to use in my app but it does not do anything as far as I can tell:
enum CKAccountStatus : Int {
case CouldNotDetermine
case Available
case Restricted
case NoAccount
}
I've been at this for awhile now and I know I'm missing something but I can't seem to figure out what it is! Please help!
You need to call CKContainer's accountStatusWithCompletionHandler which determines the status of the current user’s iCloud account asynchronously.
See the CloudKit Framework Reference for the CKContainer Class
https://developer.apple.com/library/prerelease/ios/documentation/CloudKit/Reference/CKContainer_class/index.html
Related
How do I check what the user sets app settings to? I think I'm supposed to be able to use UserDefaults to do this. I particularly want to check whether the user has allowed the app to access Contacts. I know how to get the setting if I knew the key. I would like to be able to access all the settings that UserDefaults have for the app. I am using Swift to create an iOS app.
You are misunderstanding what the UserDefaults class does. It has no knowledge of the user's settings. It's used for you to save a user's settings (from within your app) persistently.
As for how to access that kind of information. You have to use each of the APIs to check for permissions. For example, access to the GPS requires you to use LocationManager API and check the permission there.
To check if a user has given access to Contacts you have to use the Contacts API (link here)
More specifically this method:
class func authorizationStatus(for entityType: CNEntityType) -> CNAuthorizationStatus
EDIT:
You should really read on what the UserDefaults class is for. (link here)
You can't use UserDefaults to check whether the user has allowed the app to access Contacts. Try the following code.
let status = CNContactStore.authorizationStatus(for: CNEntityType.contacts)
switch (status) {
// Not determined or restricted (e.g.Parent control)
case CNAuthorizationStatus.notDetermined,CNAuthorizationStatus.restricted:
// Denied
case CNAuthorizationStatus.denied:
// Allowed
case CNAuthorizationStatus.authorized:
}
Just like the title states, I am working on contacts app. What I would like to know is if there is a way for me to find out if the contacts are reachable through FaceTime? Is there a public API for it? (Note: Solutions like ChatKit.framework for iMessage are not really acceptable, i.e. private APIs)
UPDATE: found a post here, that partially answers the question: FaceTime programmatically
UPDATE #2: using #"//facetime:" scheme does not seem to work at all, as I always get true in return
UIApplication.sharedApplication().canOpenURL(NSURL(string: "facetime://0000000000")!)
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];
}
I'm looking at integrating support for tracking Facebook's new mobile app ads.
I've read the tutorial here:
https://developers.facebook.com/docs/tutorials/mobile-app-ads/
It says:
Include the following code to be executed when your app opens for the first time by user
[FBSettings publishInstall:appId];
So the first question is - where do I put this so that it only invokes the call if the install was driven from Facebook? I don't want FB to get credit for someone who found my app themselves on the app store.
Do I need to manually track whether or not I've called the publishInstall before for this specific user? (The preamble sentence implies this - but the SDK documentation for publishInstall implies otherwise).
And even more confusing is that the SDK FBSettings reference includes shouldAutoPublishInstall which defaults to YES. This would suggest that I don't need to do anything other than have the SDK integrated. So why does the tutorial not mention this as an option?
I assume that the appId is the associated Facebook appId (as opposed to the App Store App ID). This is also not clear from the documentation.
I browsed the sources of facebook iOS SDK, and it seems that guide is wrong.
You are right, that autoPublishInstall is set to YES by default, which means we don't need to invoke [FBSettings publishInstall:appId]; manually. AppId is indeed the facebook app id.
When you invoke openActiveSessionWith.... method, it initializes FBSession with
initWithAppID:permissions:defaultAudience:urlSchemeSuffix:tokenCacheStrategy: which contains in the end [FBSettings autoPublishInstall:self.appID];
+ (void)autoPublishInstall:(NSString *)appID {
if ([FBSettings shouldAutoPublishInstall]) {
dispatch_once(&g_publishInstallOnceToken, ^{
// dispatch_once is great, but not re-entrant. Inside publishInstall we use FBRequest, which will
// cause this function to get invoked a second time. By scheduling the work, we can sidestep the problem.
[[FBSettings class] performSelector:#selector(publishInstall:) withObject:appID afterDelay:FBPublishDelay];
});
}
}
So technically it should report the install out of the box (if I'm not missing something). I'm going to play with it a little more today to see if it works as expected and update answer with results.
Just put it at -[application:didFinishLaunchingWithOptions].
Not all of the apps want to integrate the Facebook login. They only want the feature "mobile app install ads". For these kind of app, they should invoke +[FBSettings publishInstall:appId] manually. On the other hand, if your app has already integrated facebook login, you can assume that the FB sdk has published the installation.
If we just have to put
[FBSettings publishInstall:appId];
manually in
-[application:didFinishLaunchingWithOptions]
how will I identify which install happened from facebook? I don't want FB to get credit for someone who found my app themselves on the app store.
put the code in Appdelegate DidbecomeActive method
- (void)applicationDidBecomeActive:(UIApplication *)application
hope this help :)
I am using the official facebook ios sdk in my app (https://github.com/facebook/facebook-ios-sdk)
It was all working fine. I was able to log in, pull all my info from Facebook, post things on my wall. Do all those regular stuff that you do...
But since last night, it appears to be broken. When the login window appears and the user logs in, instead of getting the authkey and getting a callback. The login window directs users to facebook.com.
Did anyone else notice the problem? Is there any fix to it or we just assume that the graph API is broken right now and wait?
I assume Facebook were just having a problem. If you had it working & did not change the code then the issue is elsewhere?
In general it's a pain to get working so the following is a brief hint to anyone who is stuck.
Having spent 2 days getting this working I recommend (assuming you have registered an app with Facebook) :
First get the demo app working.
This ensures you have your app ID and worked out how to add the URL stuff into the plist. This is explained in the docs so should not give you much trouble.
Once all the options in the demo app work (login, post, upload a sample photo) you can think about your own app.
Many things are different but you still need to have the AppDelegate method for the URL stuff. Also this method does not work as is assuming your app is using more than one view controller.
I went for the approach of setting up facebook in the app delegate eg:
Facebook *facebook
and in the actual facebook routine referencing that appDelegate's facebook object eg:
appDelegate.facebook
This approach is the subject of quite a few posts on the interweb so you should be able to google it.
I can log on, get info, post & upload photos.
I'm having the same issue, i downloaded the "official example" from gitHub, and wehn compiled it does she#. After i login, it open safari and redirects to http://www.facebook.com/connect/uiserver.php, and the app stalls. Well that's not the way to do it, Facebook. They are obsoleting the old rest api, meanwhile the "new" graph things not working. Im currently using graph API with my own calls to graph.
Check if you have done the following
1.URL scheme corresponding to your Facebook application ID is set. Your URL Schemes must contain item looking like "fb1234567890"
2.AppDelegate's method must be implemented:
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
it is described in https://github.com/facebook/facebook-ios-sdk "Authentication and Authorization".
Read also "Single Sign-On".