Snowplow Objective-C Tracker 0.8.0 released

01 May 2018  •  Mike Hadam

We are pleased to release version 0.8.0 of the Snowplow Objective-C Tracker. This release introduces data consent tracking, push notification tracking, a Swift demonstration app, and several updates and bug fixes.

In the rest of this post we will cover:

  1. Data consent tracking
  2. Push notification tracking
  3. Swift demonstration app
  4. XCode 9 bugfixes
  5. Other changes
  6. Upgrading
  7. Getting help

1. Data consent tracking

Against the backdrop of the upcoming GDPR and ePrivacy regulations, this release adds new events to track when users give their consent to, and withdraw their consent from, various forms of data collection.

We envision that many digital businesses will want to track the consent of their users against relatively finegrained “bundles” of specific data usecases, which we model in Snowplow as consent documents.

The two new consent tracking methods are:

  1. trackConsentGrantedEvent, for the giving of consent
  2. trackConsentWithdrawnEvent, for the removal of consent

Each consent event will be associated to one or more consent documents, attached to the event as contexts.

Here is an example of a user opting out of data collection per a specific consent document 1234:

SPConsentWithdrawnEvent *event = [SPConsentWithdrawnEvent build:^(id<SPConsentWithdrawnBuilder> builder) {
  [builder setDocumentId:@"1234"]; // Set the document ID
  [builder setVersion:@"version"]; // Set the document version
  [builder setName:@"name"]; // Set the document name
  [builder setDescription:@"description"]; // Set the document description
  [builder setAll:false]; // Do not withdraw all consent
}];

[tracker trackConsentWithdrawnEvent:event];

2. Push notification tracking

The tracker now has support for tracking push notifications. trackPushNotificationEvent can be called on the tracker instance from inside any of the push notification methods implemented in AppDelegate.

An example can be found in the Swift demo app, implemented using the notification API in iOS 11.2 ([UserNotifications][usernotifications]). It looks likes this:

// Populate the information found in the notification content, i.e. UNNotificationContent or userInfo in 
SPNotificationContent *content = [SPNotificationContent build:^(id<SPNotificationContent> builder) {
  [builder setTitle:@"Example title"];
  [builder setSubtitle:@"Example subtitle"];
  [builder setBody:@"Example body"];
  ...
}];

SPPushNotification *event = [SPPushNotification build:^(id<SPPushNotificationBuilder> builder) {
  [builder setAction:@"1234"]; // Set the action selected by user
  [builder setTrigger:@"PUSH"]; // Set the push notification type
  [builder setEventType:@"version"]; // Set the event type e.g. "open", when the user opens the app
  [builder setCategoryIdentifier:@"name"]; // Set the category identifier of the notification
  [builder setThreadIdentifier:@"description"]; // Set the thread identifier of the notification
  [builder setNotification:notification]; // Set the notification content
}];

[tracker trackPushNotificationEvent:event];

Documentation can be found here.

3. Swift demonstration app

To provide an example of how the tracker integrates into a Swift project, we’ve added a Swift demonstration app to the repo.

For additional information regarding integrating the tracker into a Swift project, the documentation has been updated to address common issues like exception handling, and importing.

It’s also important to familiarize yourself with how to view generated interfaces - essential for finding the type signatures of the tracker methods when translated from Objective-C to Swift.

4. XCode 9 bugfixes

To improve compatibility with XCode 9 we have fixed a naming conflict in the SnowplowTests bundle (issue #343).

5. Other changes

Other updates include:

  • Adding trackSelfDescribingEvent method as an alias for trackUnstructEvent (issue #272)
  • Replacing NSGregorianCalendar with NSCalendarIdentifierGregorian (issue #329)
  • Adding preprocessor flags to disable OpenIDFA or IDFV as required (issue #334)
  • Adding identifyUser as an alias for setUserId (issue #341)
  • Dropping iOS 8 as a test target, and adding iOS 10 and 11 (issue #344)
  • Add method to SPTracker to get the session’s userId (issue #345)
  • Fix truncation of structured event value to 6 digits (issue #299)

Many thanks to Josh Sklar for contributing on issue #345, and Gordon Childs for contributing on issue #299!

6. Upgrading

To add the Snowplow Objective-C Tracker as a dependency to your own app, add the following into your Podfile:

pod 'SnowplowTracker', '~> 0.8'

If you prefer, you can manually add the tracker’s source code and dependencies into your project’s codebase, or use the Static Framework for iOS.

7. Getting help

As always, please check out the following links:

If you have an idea for a new feature or want help getting things set up, please visit our Discourse forum. And raise an issue if you spot any bugs!