facebook ios sdk log : strange message - ios

I've got a button to share an image and every times I click it, I've got this message in the log, I dont understand :
2012-08-12 19:21:30.511 AvisOcean[2239:707] An instance 0xe6b8fe0 of class FBSessionManualTokenCachingStrategy was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info:
(
Context: 0xa5e90, Property: 0x245310>
Context: 0xa5e90, Property: 0x28c400>
)
Any ideas?

The Facebook SDK is leaking observers. I am using SDK v3.1.
This shouldn't be an issue if you are using the SDK without the deprecated headers (ie Facebook.h). But to use native dialogs you need to include the deprecated headers (source: https://developers.facebook.com/docs/howtos/feed-dialog-using-ios-sdk/) which leads to this error when closing/cleaning the active session.
Here is a pull request to fix it: https://github.com/facebook/facebook-ios-sdk/pull/474
You can then rebuild the SDK using Facebook SDK for iOS6/Xcode 4.5 not working

I was having the same problem. I think what had happend is I had initialized Facebook else where and it was giving me errors when I tried to re-initialize it and again invoke a dialog delegate from a different instance.
The instance where i was keeping actual app initialization and accesstoken were different from the one which was invoking the dialog. When I corrected that after going over the documentation, it was solved.
if (nil == self.facebook) {
self.facebook = [[Facebook alloc]
initWithAppId:FBSession.activeSession.appID
andDelegate:nil];
// Store the Facebook session information
self.facebook.accessToken = FBSession.activeSession.accessToken;
self.facebook.expirationDate = FBSession.activeSession.expirationDate;
}
[self.facebook dialog:#"feed" andParams:params andDelegate:self];

Do a quick logout prior to assigning accessToken and expirationDate, that will help clean up some nasty error that you had seen. I'm sure this is just a temporary solution for those using deprecated Facebook headers.
// Initiate a Facebook instance
if(!_facebook)
_facebook = [[Facebook alloc] initWithAppId:FBSession.activeSession.appID andDelegate:nil];
// Store the Facebook session information
[_facebook logout];
_facebook.accessToken = FBSession.activeSession.accessToken;
_facebook.expirationDate = FBSession.activeSession.expirationDate;

I see this message when my Facebook object is dealloc'ed. I'm using the 3.0.8 SDK. In my case I'm thinking that the Facebook object should remove itself as an observer of its tokenCaching before releasing it in its dealloc. Your case might be different since it doesn't sound like you'd be clearing the FB object. Perhaps the suggestions here would help.

Related

Mixpanel integrated in iOS SDK is not sending events

​I have an iOS SDK project with lots of modules (in Objective-C).
I want to start tracking events to see how my clients use our SDK but I can't see anything in the insights tab. What am I doing wrong?
 
In the point of entry to the SDK I have added this (just following the docs):
[Mixpanel sharedInstanceWithToken:#"myTOKEN"];
self.mixpanel.serverURL = #"https://api-eu.mixpanel.com";
[self.mixpanel track:#"Video play" properties:#{
#"genre": #"hip-hop",
#"duration in seconds": #42,
}];
I can see with breakpoints that the code it’s executed, however my insights are completely empty.
I also tried adding events with the codeless tracking, and while it looks like it’s working and I can connect to the app, the events aren’t appearing in the insights tab.
 
​
I think you need to assign the shared instance to your local property if that hasn't been done outside of the code you've posted.
[Mixpanel sharedInstanceWithToken:#"myTOKEN"];
self.mixpanel = [Mixpanel sharedInstance]; // assign here
self.mixpanel.serverURL = #"https://api-eu.mixpanel.com";
[self.mixpanel track:#"Video play" properties:#{
#"genre": #"hip-hop",
#"duration in seconds": #42,
}];

How do you cancel a Nest ETA using Firebase on iOS?

According to the nest API docs:
"To cancel an eta, send estimated_arrival_window_begin = 0. Check that you're sending an integer (0) in this call, not a string ("0"), or the call will fail."
See https://developers.nest.com/documentation/cloud/eta-reference/
My code is based on the iOS NestDK sample which uses Firebase.
I set things up using the addSubscriptionToURL method as follows: ​
[[FirebaseManager sharedManager] addSubscriptionToURL:[NSString stringWithFormat:#"structures/%#/eta", structureId] withBlock:^(FDataSnapshot *snapshot) {}];
I can then make successful calls to set an eta window for a specific trip.
However, i can't seem to be able to cancel the eta for the same trip. If i just specify the trip_id and estimated_arrival_window_begin properties i get an error message complaining that the estimated_arrival_window_end field is missing.
NSMutableDictionary *values = [[NSMutableDictionary alloc] init];
[values setValue:[_tripId UUIDString] forKey:#"trip_id"];
[values setValue:[NSNumber numberWithInt:0] forKey:#"estimated_arrival_window_begin"];
[[FirebaseManager sharedManager] setValues:values forURL:[NSString stringWithFormat:#"structures/%#/eta", structureId]];
I tried also setting estimated_arrival_window_end to 0 but i then get an error message saying that the estimated_arrival_window_begin is in the past. It seems to be interpreting the 0 value as the beginning of time. Well some time in 1970 anyway!
What am i doing wrong here?!
Thanks!
Are you using a Nest account with virtual devices created with the Nest Home Simulator? There appears to be a bug using virtual devices versus real devices. Please try using a Nest account with real devices.

ShareKit 2.0 facebook share URL

I have the following code for sharing with facebook using ShareKit:
-(void)buttonAction:(id)sender
{
[SHK setRootViewController:self];
SHKItem *facebookItem = [[SHKItem alloc] init];
facebookItem = [SHKItem URL:[NSURL URLWithString:#"www.google.com"] title:#"Some test title"];
facebookItem.facebookURLSharePictureURI = #"www.myTestPicture.com";
facebookItem.facebookURLShareDescription = #"Custom share description";
[SHKFacebook shareItem:facebookItem];
}
Everything works fine except for one scenario. My application has a log out button. Upon hitting this button, all the data save in NSUserDefaults gets erased. So, I log in and then make a post to facebook. Then, I log out (erase all the data) and afterwards log back in with facebook. Everything works so far. However if I try to make another post to facebook at this point, my application crashes with no error showing up in the console. If I restart the application and try to make the same post again, it works. It only crashed after loging out, back in (with facebook) and then trying to make the post. Any clues? Thanks.
EDIT: Seems like it is crashing in FBDialog at line 341:
_webView = [[UIWebView alloc] initWithFrame:CGRectMake(kPadding, kPadding, 480, 480)];
Ok, so after some digging aroung here, it seems to be Apple's bug in iOS 5.1 according to Why does clearing NSUserDefaults cause EXC_CRASH later when creating a UIWebView?

Determine if previously installed app

I have an app on the App Store, and I want to make some changes that will not effect users that previously downloaded my app.
Is there a way to determine if the user has previously downloaded my app?
Incase anyone is still wondering, a great solution to this problem (assuming you don't already have it) is using the Keychain, which persists through app installation/uninstalls. This library allows you to access the Keychain using NSDictionary-like syntax.
https://github.com/nicklockwood/FXKeychain
So you could implement a function like this:
-(BOOL)alreadyInstalled
{
NSString *installDate = [[FXKeychain defaultKeychain] objectForKey:#"InstallDate"];
if (!installDate)
{
NSString *newInstallDate = [NSString stringWithFormat:#"%i", [[NSDate date] timeIntervalSince1970]];
[[FXKeychain defaultKeychain] setObject:newInstallDate forKey:#"InstallDate"]
return NO;
}
return YES;
}
I don't know a great way to do this but there are some tricks you can do, e.g.:
Look for some data that your application generates. If the data already exists then it's not an update (or an update that completed previously);
Prepare yourself for this, even if this means issuing an intermediate update to your application, then go back to #1. See: How to tell if an iOS application has been newly installed or updated?

Cannot remove an observer <MKUserTrackingBarButtonItem

- (void)viewWillAppear:(BOOL)animated
{
MKUserTrackingBarButtonItem *trackingBarButtonItem = [[MKUserTrackingBarButtonItem alloc]initWithMapView:_mapView];
NSArray *barButtonItems = [NSArray arrayWithObjects:trackingBarButtonItem, nil];
mapToolbar.items = barButtonItems;
...
}
Code works fine on iPhone, but on iPad when view is unloading I get an error:
Cannot remove an observer <MKUserTrackingBarButtonItem 0x9cc0930> for the key path
"controlSize" from <UIButton 0x991b420> because it is not registered as an observer.'
I contacted Apple DTS and their answer was:
"To the best of my knowledge there is no workaround for this in the current shipping SDK. I would check the latest iOS SDK beta though and see if this is still an issue."

Resources