-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[ios] Add SDK version update checking/notification #8282
[ios] Add SDK version update checking/notification #8282
Conversation
@friedbunny, thanks for your PR! By analyzing this pull request, we identified @1ec5, @incanus and @boundsj to be potential reviewers. |
@@ -43,6 +43,9 @@ | |||
/* Action sheet title */ | |||
"SDK_NAME" = "Mapbox iOS SDK"; | |||
|
|||
/* Developer-only SDK update notification; {latest version, in format x.x.x} */ | |||
"SDK_UPDATE_AVAILABLE" = "現在Mapbox iOS SDK %1$@が入手できる:"; |
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.
In general, you should wait until Transifex notices the new base string to translate it over there, rather than checking the translation in ahead of time.
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 added this as a way to validate my localization implementation — should we take it out?
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'm not sure. I guess we can leave it in and take it out if there's any fallout.
platform/ios/src/MGLMapView.mm
Outdated
@@ -564,6 +565,8 @@ - (void)commonInit | |||
if ([UIApplication sharedApplication].applicationState != UIApplicationStateBackground) { | |||
[MGLMapboxEvents pushEvent:MGLEventTypeMapLoad withAttributes:@{}]; | |||
} | |||
|
|||
[MGLSDKUpdateChecker checkForUpdates]; |
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.
Have you considered implementing this check in a +load
method?
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 also like the idea of calling this from the load
or initialize
class methods. If you do move it, calling from initialize
like Realm do may be slightly safer since this ends up making a network call but probably fine either way.
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.
+load
in MGLMapView or MGLSDKUpdateChecker?
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.
(Responded initially without refreshing and seeing @boundsj comments.)
Sure, we can move this to a new +load
or +initialize
in MGLMapView. This update check is clearly not essential, so that’s why I dropped it at the end of -commonInit
.
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.
Moved this call to +[MGLMapView initialize]
in 4d3f390.
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.
+[MGLOfflineStorage initialize]
or -[MGLOfflineStorage init]
would also cover the case where the developer uses offline packs early on but buries the map view in a secondary screen. But that's an edge case, so I'm fine with putting it here. Basically we want this check to happen early on while the developer is still paying attention.
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.
Fine with putting it in +[MGLMapView initialize]
, that is.
+ (void)checkForUpdates { | ||
#if TARGET_IPHONE_SIMULATOR | ||
// Abort if running in a playground. | ||
if ([[NSBundle mainBundle].bundleIdentifier hasPrefix:@"com.apple.dt.playground."]) { |
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.
Does this run as part of the Interface Builder designable agent process? You can use -[NSProcessInfo(MGLAdditions) mgl_isInterfaceBuilderDesignablesAgent]
to check for that condition.
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.
Will investigate this — likely no harm in adding such a guard, anyway.
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.
Did not see evidence of the update check being called in IB, but IB is also failing to load our designable anyway... so I added the process exclusion in 470c6c0.
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 later realized we bail in IB at the beginning of -commonInit
. But this is a good check to add now that we're running code in the initialize method.
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.
This is great! I agree with @1ec5's that we should investigate moving the call and try to make sure this check does not happen because of IB. It'd be great to land this for the next 3.5.0 release later this week.
platform/ios/src/MGLMapView.mm
Outdated
@@ -564,6 +565,8 @@ - (void)commonInit | |||
if ([UIApplication sharedApplication].applicationState != UIApplicationStateBackground) { | |||
[MGLMapboxEvents pushEvent:MGLEventTypeMapLoad withAttributes:@{}]; | |||
} | |||
|
|||
[MGLSDKUpdateChecker checkForUpdates]; |
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 also like the idea of calling this from the load
or initialize
class methods. If you do move it, calling from initialize
like Realm do may be slightly safer since this ends up making a network call but probably fine either way.
👍 to the link being to s3 |
I think we’re ready to go here. Should this have a changelog entry? |
Yes, I think it should have a changelog entry. |
4d3f390
to
a6bbf09
Compare
This looks great. |
Moving the responsibility for updating and hosting the checker file to the ios-sdk site in #8468. |
Implements #7311 for iOS. This adds a check that the developer is using the latest stable release of our iOS SDK and, if not, prints a note to console with a link to the new release.
Inspired by Realm’s update check. 🙇
x.x.x
SDK_UPDATE_AVAILABLE
string that can be localized./cc @incanus @tobrun