building an invisible app

Post on 22-Jan-2017

215 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

06.11.15

@braintree_dev @alanhhwong

Building an Invisible App

Alan Wong <developer-advocate/>

PayPal & Braintree

>since 2013

@braintree_dev @alanhhwong

20% of all apps are used only ONCE!

http://info.localytics.com/blog/app-retention-improves

http://readwrite.com/2012/01/17/study_average_app_session_lasts_about_1_minute

Average App Session Lasts About 1 Minute

How do you make this count?

Background Services

1. Location

2. Read Calendar

3. Calculate commute

4. Display Notification

> Location

>Significant-change location service

>Background location services

- (void)startSignificantChangeUpdates { // Create the location manager if this object does not // already have one. if (nil == locationManager) locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; [locationManager startMonitoringSignificantLocationChanges]; }

// Delegate method from the CLLocationManagerDelegate protocol. - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { CLLocation* location = [locations lastObject]; NSDate* eventDate = location.timestamp; NSTimeInterval howRecent = [eventDate timeIntervalSinceNow]; if (abs(howRecent) < 15.0) { // If the event is recent, do something with it. NSLog(@"latitude %+.6f, longitude %+.6f\n", location.coordinate.latitude, location.coordinate.longitude); } }

> Location

>Significant-change location service

>Background location services

EKEventStore *store = [store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error)

{ // handle access here }];

// Get the appropriate calendar NSCalendar *calendar = [NSCalendar currentCalendar];

// Create the start date components NSDateComponents *oneDayAgoComponents = [[NSDateComponents alloc] init]; oneDayAgoComponents.day = -1; NSDate *oneDayAgo = [calendar dateByAddingComponents:oneDayAgoComponents toDate:[NSDate date] options:0];

// Create the end date components NSDateComponents *oneYearFromNowComponents = [[NSDateComponents alloc] init]; oneYearFromNowComponents.year = 1; NSDate *oneYearFromNow = [calendar dateByAddingComponents:oneYearFromNowComponents toDate:[NSDate date] options:0];

// Create the predicate from the event store's instance method NSPredicate *predicate = [store predicateForEventsWithStartDate:oneDayAgo endDate:oneYearFromNow calendars:nil];

// Fetch all events that match the predicate NSArray *events = [store eventsMatchingPredicate:predicate];

> Read Calendar Event

> Get access -> retrieve event

MKDirectionsRequest *walkingRouteRequest = [[MKDirectionsRequest alloc] init]; walkingRouteRequest.transportType = MKDirectionsTransportTypeWalking; [walkingRouteRequest setSource:[startPoint mapItem]]; [walkingRouteRequest setDestination :[endPoint mapItem]];

MKDirections *walkingRouteDirections = [[MKDirections alloc] initWithRequest:walkingRouteRequest];

[walkingRouteDirections calculateDirectionsWithCompletionHandler: ^(MKDirectionsResponse * walkingRouteResponse, NSError *walkingRouteError) { if (walkingRouteError) { [self handleDirectionsError:walkingRouteError]; } else { self.walkingRoute = walkingRouteResponse.routes[0]; } }];

> Calculate Commute

> With location + destination, use Map Kit (MKDirections) to compute ETA

- (IBAction)setNotification:(UIButton *)sender { UILocalNotification *notification = [[UILocalNotification alloc] init]; notification.fireDate = dateTime; notification.alertBody = @“Time to leave!"; notification.soundName = UILocalNotificationDefaultSoundName; notification.applicationIconBadgeNumber = 1; [[UIApplication sharedApplication] scheduleLocalNotification:notification]; }

> Display Notification

> Use local notification

1. Tokenization

2. Vault

> Tokenizing Cardholder Data

Card Number Card Verification Code

Expiration Date ..}

c32bk4g98Ad32 ...

> Vault

> Securely store payment method using the nonce

> Create a transaction using stored payment methods

FIVE Things To Consider

1. Don’t automate everything

2. Use Notifications

3. Usage Patterns

4. Make Use of Location

5. Establish Trust

06.11.15

@braintree_dev @alanhhwong

Thank you.Questions?Alan Wong <developer-advocate/>

PayPal & Braintree

top related