-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tvOS support #571
tvOS support #571
Conversation
- Fixed a bug that caused an incomplete set of traits to be persisted to NSUserDefaults - On tvOS, switched the order of loading of traits and the queue so it's attempted from the file first, then NSUserDefaults - Updated the Podspec - Bumped the version to 3.2.6 - Added a tvOS deployment target version (9.0)
NSUserDefaults to only NSUserDefaults on tvOS
Hey @justindhill - looks like the compilation works fine but the Podspec does not validate. you can run https://cloudup.com/cfQaMXWRBEO
Some of these are actually the same warnings I was stuck at last time I looked into this #509 (comment). The good thing is there are no errors now, just warnings! So if we can fix the warnings that'd be great. Additionaly I'd like to do some manual testing on tvOS for a sanity check as well. |
Hey @f2prateek, resolved all but one of the linting errors. The last one is caused by the use of NSURLConnection in |
However, that one is a warning and can be resolved at your leisure. |
@justindhill Thanks, we can take care of that separately- we do have an open issue for migrating to NSUrlSession but haven't had time to tackle it. Do you know if it's possible to have CocoaPods ignore a specific error (other than supressing all with |
You can suppress warning emissions within a particular block of code using the preprocessor.
|
[self.location startUpdatingLocation]; | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might want to move this lower down - to right before return [context copy];
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know that I agree. CoreLocation is still available on tvOS, as well as CLLocationManager, but it doesn't provide periodic updates like it does on iOS. Presumably, this is because Apple doesn't anticipate the device moving while it's in use. 😜
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see, that makes sense!
We'll want to remove this entire block:
|
Probably only want to remove it on tvOS, right? I guess the purpose of it was to flush data from NSUserDefaults after you rolled back to file-based storage. |
@@ -586,16 +611,26 @@ - (void)applicationWillTerminate | |||
- (NSMutableArray *)queue | |||
{ | |||
if (!_queue) { | |||
#if TARGET_OS_TV | |||
_queue = [[NSUserDefaults standardUserDefaults] objectForKey:SEGQueueKey]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @justindhill , this will need to be _queue = [[NSUserDefaults standardUserDefaults] objectForKey:SEGQueueKey]; ?: [[NSMutableArray alloc] init];
. Without that, the queue is always nil
since nothing has been stored for that key, and none of the payloads are added to the queue, as a result of which nothing is persisted or uploaded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good catch
@justindhill Yup that was indeed the purpose. Let's remove those LOC just from tvOS for now. |
return _queue; | ||
} | ||
|
||
- (NSMutableDictionary *)traits | ||
{ | ||
if (!_traits) { | ||
#if TARGET_OS_TV | ||
_traits = [[NSUserDefaults standardUserDefaults] objectForKey:SEGTraitsKey]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as for the queue, this should fallback to [[NSMutableDictionary alloc] init]
_traits = [[NSUserDefaults standardUserDefaults] objectForKey:SEGTraitsKey] ?: [[NSMutableDictionary alloc] init];
I tested this with the |
Great, I made those changes in f9eddea! |
@@ -496,6 +525,8 @@ - (void)reset | |||
[self dispatchBackgroundAndWait:^{ | |||
[[NSUserDefaults standardUserDefaults] setValue:nil forKey:SEGUserIdKey]; | |||
[[NSUserDefaults standardUserDefaults] setValue:nil forKey:SEGAnonymousIdKey]; | |||
[[NSUserDefaults standardUserDefaults] setValue:@[] forKey:SEGQueueKey]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this and the line below be only on tvOS as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, yes.
instead of nil - When resetting, only remove storage files when we are not on tvOS - When retrieving collection objects from NSUserDefaults, make a mutable copy, as all collections retrieved from NSUserDefaults are immutable
Thanks, tested manually and merged in #572 |
No description provided.