Commit Graph

123 Commits

Author SHA1 Message Date
Justin R. Miller
00f9a477b7 abbreviate syntax for unused parameters 2015-07-08 22:58:50 -07:00
Minh Nguyễn
0e3270cb15 Replaced user-facing assertions with exceptions
Errors caused by client code should be communicated through NSExceptions. NSAsserts are intended for internal usage; because they include helpful information like the absolute path to the file containing the assertion, stripping the build (#1650) also strips assertion messages. Also replaced hardcoded references to methods in these messages with __PRETTY_FUNCTION__, which avoids future copy-pasta and handles cases in which the MGL class has been subclassed.
2015-06-18 10:59:12 -07:00
Minh Nguyễn
91641ffb01 Lightweight generics
Added lightweight generics annotations to collection-typed method and protocol signatures to streamline usage of these members in Swift. Lightweight generic type specifiers are wrapped in conditionally-compiled macros for compatibility with Xcode 6.x.

Manually preprocess the NS_*_OF() macros in a temporary copy of each header before appledoc sees the headers. Also removed the --ignore flag because we no longer have a private headers folder under include/mbgl/ios/.
2015-06-17 15:33:00 -07:00
Minh Nguyễn
f46328655e Audited headers for nullability
Added some nullability qualifiers in method implementation selectors for consistency with declarations.

The user dot view now has a non-zero size. Previously only its layer was sized properly. Also resolved some pedantic warnings about missing designated initializer overrides.

Xcode 6.3 or above is now required for building this project.
2015-06-11 11:37:23 -07:00
Brad Leege
70acae7941 #1659 - Converting true to YES, false to NO to match Objective C standards 2015-06-01 15:06:32 -05:00
Brad Leege
ebe1e2158c #1659 - Converting usingTestServer to atomic property 2015-06-01 15:05:01 -05:00
Brad Leege
d44450ac7b #1659 - Adding tile stream certificate and ssl pin check for test server. 2015-05-28 15:51:50 -07:00
Brad Leege
d0864d719b #1641 - Changing version to a static constant instead of a property 2015-05-26 14:24:02 -07:00
Brad Leege
ad0a2af6b5 #1641 - Adding version and instance to Turnstile event and keeping them DRY for general events processing 2015-05-26 13:50:01 -07:00
Minh Nguyễn
70381d2705 Fixed up various Info.plist edge cases
Need to look in the main bundle for Info.plist settings, because the developer has no access to the framework’s Info.plist. Need to check MGLMapboxMetricsEnabledSettingShownInApp before MGLMapboxAccessToken; otherwise, `MGLMapboxEvents` inspects the Settings bundle plist before MGLMapboxMetricsEnabledSettingShownInApp is even checked.
2015-05-21 01:49:53 -07:00
Minh Nguyễn
256b748458 Merge branch '1ec5-plist-1535' 2015-05-20 14:38:36 -07:00
Brad Leege
a47438d42a #1595 - Changing to strongSelf 2015-05-20 15:12:48 -05:00
Brad Leege
cbcc3a3e49 #1595 - Separating pushTurnstileEvent from primary pushEvent infrastructure. Adding event, created, and appBundleId to posted Turnstile Event data model. 2015-05-20 15:05:56 -05:00
Brad Leege
a29587726c #1595 - Moving MGLEventTypeAppUserTurnstile event to end of MGLMapboxEvents init method to ensure it only gets called once 2015-05-20 14:32:16 -05:00
Brad Leege
44caf2c7a9 #1595 - Improving stability by moving MGLEventTypeAppUserTurnstile after the strongSelf check 2015-05-20 14:18:39 -05:00
Brad Leege
a5bd2fa3c6 #1595 - Adding exception so that Turnstile event will always be sent in 2015-05-20 12:31:20 -05:00
Brad Leege
58b967605a Implementing suggestions to tighten up MGLAccountManager and rename MGLEventTypeUserCount to MGLEventTypeAppUserTurnstile 2015-05-20 11:32:57 -05:00
Brad Leege
f3d7212137 #1595 - Adding App User count event to be triggered and immediately sent when Access Token is set. 2015-05-19 17:02:54 -05:00
Brad Leege
fa34b53964 #1396 - Refactoring Metrics Test Server URL configuration to be drive via Info.plist 2015-05-18 18:15:15 -05:00
Minh Nguyễn
2c7d0567fa Privatized MGLMapboxEvents
`-pauseMetricsCollection` and `-resumeMetricsCollection` were originally introduced to mitigate concerns around battery usage, but `MGLMapboxEvents` has since evolved to tread much lighter on the battery. There’s no longer any need for the client to call these methods directly. The iOS test project now includes MGLMapboxEvents.h explicitly to avoid having to package a header that will go unused.
2015-05-18 11:55:54 -07:00
Minh Nguyễn
a04703e2d5 Updated Metrics in-app opt-out assertion
The message referred to `+[MGLAccountManager setMapboxMetricsEnabledSettingShownInApp:]`, which is no longer available.
2015-05-14 00:38:52 -07:00
Minh Nguyễn
2529baa62b Grab access token and other app-wide data from Info.plist
That way there’s no ambiguity about when you should call things like `+[MGLAccountManager setMapboxMetricsEnabledSettingShownInApp:]`. In fact, that method is now deprecated because it’s so easy to call in the wrong place.

Fixes #1535.
2015-05-13 15:33:28 -07:00
Minh Nguyễn
9a404a3088 Return nil for IB designables agent
In Objective-C, the return value for a non-void method is the receiver by default. Hello NeXTSTEP.
2015-05-13 07:53:32 -07:00
Justin R. Miller
190e911209 fix dispatch-thread pattern
1. Always bail early if in IB.
 2. Always run on main thread if not already.
 3. THEN dispatch_once to create the static instance.
2015-05-12 18:23:59 -07:00
Minh Nguyễn
7ed31065ed Cleaned up in-app opt-out property
Renamed the property to be consistent with the public class methods. Also removed a spurious #import of a .m file.
2015-05-12 16:16:48 -07:00
Minh Nguyễn
9850488253 Merge branch '1ec5-metrics-determinism' into 1ec5-metrics-opt-way-out 2015-05-12 16:12:25 -07:00
Minh Nguyễn
b1992a4516 Merge branch 'master' into 1ec5-metrics-opt-way-out 2015-05-12 16:09:10 -07:00
Minh Nguyễn
afbb9c2717 Enable Metrics by default default default
Enable Mapbox Metrics by default when Settings.bundle is absent, but allow Settings.bundle to override the default. Don’t register defaults for non-Mapbox preferences. The two-phase registration ensures that the defaults don’t default to unexpected values, yet gives the developer a chance to call `+[MGLAccountManager mapboxMetricsEnabledSettingShownInApp]` before the hard assertion.

Fixes #1518.
2015-05-12 15:26:07 -07:00
Minh Nguyễn
b88b917cd4 Acknowledge the existence of other Mapbox GL classes 2015-05-12 12:28:43 -07:00
Minh Nguyễn
576caf0855 Corrected Settings.bundle assertion message
It’s `-[MGLAccountManager setMapboxMetricsEnabledSettingShownInApp:]`. Also clarified when the setter has to be called.
2015-05-12 11:49:40 -07:00
Brad Leege
87551c6d0e #1516 - Renaming setShowsOptOutInApp to setMapboxMetricsEnabledSettingShownInApp for app consistency. Implementing wordsmith edits to NSAssert text. Removing technical debt. 2015-05-12 10:50:46 -05:00
Minh Nguyễn
54a703bcb2 Consolidated logic for pausing/resuming MGLMapboxEvents
`MGLMapboxEvents` automatically recreates its location manager when the host app is reauthorized for Location Services. Added some redundancy to ensure that there is no location manager when either Location Services or Mapbox Metrics is off.
2015-05-12 01:38:04 -07:00
Minh Nguyễn
58d695f6d3 Respond to opt-out setting change immediately
As soon as the user returns to the host app after changing the opt-out preference in Settings, `MGLMapboxEvents` responds by pausing or resuming. Also moved the IB designables agent check to occur only once, at launch, since the process name is not expected to change mid-session.
2015-05-12 01:38:04 -07:00
Minh Nguyễn
ff0ec15e1d More cleanup and sanitization
Moved constant values from ivars into constants. Invalidate the flush timer and clear the event queue on pause. Rewrote some flush logic to be easier to follow.
2015-05-12 01:38:04 -07:00
Minh Nguyễn
2f02a6538e Folded MGLMetricsLocationManager into MGLMapboxEvents
`MGLMetricsLocationManager` was nothing but overhead for `CLLocationManager`. Also removed an unused method.
2015-05-12 01:36:56 -07:00
Minh Nguyễn
c1fe6e1890 Resume iff Metrics is enabled 2015-05-12 01:36:56 -07:00
Minh Nguyễn
f860169f35 Refactored MGLMapboxEvents for better data management
The shared `MGLMapboxEvents` now owns the only instance of `MGLMetricsLocationManager`. It also owns a `MGLMapboxEventsData` object, to which all user-specific data has been relegated. This object can be built up and torn down on the fly, whenever the opt-out preference is toggled. `MGLMapboxEvents` has also given up knowledge of the access token and now queries `MGLAccountManager` for that information, which `MGLMapView` keeps up-to-date.
2015-05-12 01:36:56 -07:00
Minh Nguyễn
60ed9e6d2e Objective-C method naming convention
Removed “get” from names of methods that perform no network or file access.
2015-05-12 01:36:29 -07:00
Minh Nguyễn
1503f33140 Predicate MGLMapboxEvents initialization on user opt-out 2015-05-12 01:36:29 -07:00
Minh Nguyễn
4837359471 Register default user defaults on class initialization
`-[MGLMapboxEvents init]` only gets called if `-[MGLMapboxEvents sharedManager]` sees that user defaults call for an `MGLMapboxEvents` to be created. But those user defaults were only being registered inside `-[MGLMapboxEvents init]`. This change moves the registration to `+initialize`, which is called as soon as the class is loaded.
2015-05-12 01:36:29 -07:00
Brad Leege
48e21ae6e9 #1516 - Adding explicit checks for developer implementation of user Opt Out functionality 2015-05-11 23:31:22 -05:00
Brad Leege
08f1d4b511 #1481 - Changing events array to be created with +arrayWithArray 2015-05-08 15:24:19 -05:00
Brad Leege
2eef6b4412 #1481 - Refactoring to use iOS -copy and -removeAllObjects to get away from having to do potentially less stable index calculations 2015-05-08 15:02:32 -05:00
Brad Leege
9d0b67450d #1481 - Replacing flushAt with eventQueue count of upper range limit 2015-05-08 14:53:39 -05:00
Minh Nguyễn
bb788f56f2 Renamed settings keys
The new keys fit the standard naming convention for Info.plist keys and more clearly communicate how they’re to be used.
2015-05-08 11:51:48 -07:00
Brad Leege
9f0e9fe847 #1474 - Setting flushAfter back to 60 seconds. Removing debug log statements 2015-05-08 10:23:14 -05:00
Brad Leege
11886a9004 #1474 - Adding timer cleanup logic to -flush so that it doesn't loop indefinitely 2015-05-08 10:21:00 -05:00
Brad Leege
ea3979b19e #1474 - Refactoring timer to be started when first event is added to queue. Debug logic and content also included 2015-05-08 10:13:05 -05:00
Minh Nguyễn
ec3757309f Fixed leaks of copied CF objects 2015-05-05 12:10:44 -04:00
Minh Nguyễn
900d140f23 Fixed dead store analyzer warnings
These values weren’t being used for anything.
2015-05-05 11:41:02 -04:00