Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

[ios] Add SDK version update checking/notification #8282

Merged
merged 2 commits into from
Mar 7, 2017

Conversation

friedbunny
Copy link
Contributor

@friedbunny friedbunny commented Mar 5, 2017

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. 🙇

  • Only runs if using the simulator — method is a no-op anywhere else, including Swift Playgrounds.
  • Version comparison is extremely simple and ignores semver — if the version strings don’t match, it assumes the developer needs to upgrade.
  • Deploy script uploads a text file to http://mapbox.s3.amazonaws.com/mapbox-gl-native/ios/latest_version with the version in format: x.x.x
  • Adds a SDK_UPDATE_AVAILABLE string that can be localized.

/cc @incanus @tobrun

@friedbunny friedbunny added build feature iOS Mapbox Maps SDK for iOS labels Mar 5, 2017
@friedbunny friedbunny added this to the ios-v3.5.0 milestone Mar 5, 2017
@friedbunny friedbunny self-assigned this Mar 5, 2017
@friedbunny friedbunny requested review from boundsj and 1ec5 March 5, 2017 04:47
@mention-bot
Copy link

@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$@が入手できる:";
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

@@ -564,6 +565,8 @@ - (void)commonInit
if ([UIApplication sharedApplication].applicationState != UIApplicationStateBackground) {
[MGLMapboxEvents pushEvent:MGLEventTypeMapLoad withAttributes:@{}];
}

[MGLSDKUpdateChecker checkForUpdates];
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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."]) {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

@boundsj boundsj left a 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.

@@ -564,6 +565,8 @@ - (void)commonInit
if ([UIApplication sharedApplication].applicationState != UIApplicationStateBackground) {
[MGLMapboxEvents pushEvent:MGLEventTypeMapLoad withAttributes:@{}];
}

[MGLSDKUpdateChecker checkForUpdates];
Copy link
Contributor

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.

@mick
Copy link

mick commented Mar 6, 2017

@mick Is s3 the best location for this link? Would it be better on https://mapbox.com/ios-sdk?

👍 to the link being to s3

@friedbunny
Copy link
Contributor Author

I think we’re ready to go here. Should this have a changelog entry?

@1ec5
Copy link
Contributor

1ec5 commented Mar 7, 2017

Yes, I think it should have a changelog entry.

@friedbunny friedbunny merged commit a6bbf09 into release-ios-v3.5.0-android-v5.0.0 Mar 7, 2017
@friedbunny friedbunny deleted the fb-update-checker branch March 7, 2017 19:50
@incanus
Copy link
Contributor

incanus commented Mar 7, 2017

This looks great.

@friedbunny
Copy link
Contributor Author

friedbunny commented Mar 19, 2017

Moving the responsibility for updating and hosting the checker file to the ios-sdk site in #8468.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
build feature iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants