22
Accelerating Mobile Application Development with Mobile Cloud Services Todd Kaplinger Senior Technical Staff Member MobileFirst for iOS Cloud Architect @todkap © 2015 IBM Corporation

Interconnect Mobile Application Development on Bluemix!!

Embed Size (px)

Citation preview

Accelerating Mobile Application Development with Mobile Cloud ServicesTodd Kaplinger Senior Technical Staff Member MobileFirst for iOS Cloud Architect @todkap

© 2015 IBM Corporation

The new normal of IT focus and investment…

Three methods of new value creation:

Alone, each of these has immense potential. Integrated, they change everything.

Drive people-centric Engagement for new profit

channels

Utilize Data as the new basis

of competitive advantage

Leverage Cloud as growth engine

for business

Building “engaging” apps is hard• Time to market requirements must be quicker… weeks not

months

• More experimental in nature… LEAN approaches to testing the market are needed.

• Mobile brings its own set of challenges… from device fragmentation to scale to surges of demand to connecting securely into enterprise data

• Greater data capture requirements… on all apps to drive analytics

• Developers of engaging apps want to use multiple languages and Cloud APIs…

The IBM MobileFirst Platform contains the ingredients for a successful mobile program

Available on premises or in the cloud.

Efficiently Develop & Integrate

Easily Secure

Personalize Engagements

Continuously Deliver

The three essential ingredients to building apps for the “new normal”

A platform to secure your apps, manage their

lifecycle, and integrate them into the enterprise

Cloud APIs that can be glued together to quickly create new apps at scale

Synchronized data across devices that can scale to

meet mobile demand

MobileFirst Apps for iOS

Swift + iOS8Simple TODO Application

BlueList Application• Bluemix Hosted • Leverages MobileFirst Services Starter

Boilerplate • Cloudant NoSQL DB • Push for iOS 8 • Advanced Mobile Access • Linked identity to data stored in cloud

Bluemix

Google+ Identity

Custom Authentication

Facebook Authentication

BlueList Application• Simple TODO list for tracking outstanding

items • Focus on Swift version designed for iOS8 • CocoaPods used for dependency

management • Available on command line via GIT

DevOps

CocoaPods

GIT Hosted on DevOps

BlueList in Swift Variant of BlueList Mobile Data written in Swift Simple TODO list for tracking outstanding items

(IBM_Item.swift Class)(2 ViewControllers / One AppDelegate / One Storyboard)

Leverages Bolts Framework to simplify data access patterns

10https://github.com/BoltsFramework/Bolts-iOS Data CRUD

BlueList Storyboard

DEMO

Acme Apparel Application• Business to Consumer (B2C) • Advanced Application

• 15 Unique Views• 10 Persisted Data Objects

• Security Integration with Mobile First Platform Advanced Mobile Access

• Push Notifications Support • Integration with 3rd Party Weather Service• MQA sentiment analysis and crash reporting • Operational Analytics calculating usage

patterns

Google+ Identity

Advanced Mobile Access• MobileFirst Services Starter

(for iOS 8) • Authentication options

• Facebook • Google+ • Custom authentication

• Register iOS app using bundle id and version

• Custom authentication set up through predefined REST API

• Use Apple Touch ID to secure MobileFirst access tokens

Social Integration • Google+ Authentication • OAUTH2 Client Side Flow • Native iOS Libraries with

Objective-C • Authentication Scope

• Profile • Access to user profile info

(email/preferred name/photo)

• Integrated with Advanced Mobile Access

/** * Executed when the Google+ authentication flow returns control to the application. */ - (void)finishedWithAuth: (GTMOAuth2Authentication *)auth error: (NSError *) error { if(!error){ [self queryGooglePlusUser]; } }

/** * Fetch the authenticated user's Google+ information. */ -(void) queryGooglePlusUser { GTLServicePlus* plusService = [[GTLServicePlus alloc] init]; plusService.retryEnabled = YES; [plusService setAuthorizer:[GPPSignIn sharedInstance].authentication]; GTLQueryPlus *query = [GTLQueryPlus queryForPeopleGetWithUserId:@"me"]; [plusService executeQuery:query completionHandler:^(GTLServiceTicket *ticket,

GTLPlusPerson *person, NSError *error) { if (error) { GTMLoggerError(@"Error: %@", error); } else { [self buildCustomer:(person)]; } }]; }

Cloudant NoSQL Database• Fully managed Cloudant NoSQL database provides data layer that is

transparent and always on • Client-side APIs provide intuitive environment for storing data on the cloud

• CRUD support, online and offline replication with only a few lines of code • Map simple objects to JSON documents using default or custom object mapper

• Object Models - Items, Shopping Cart, Stores, and Purchase History

Shopping Cart

/*! * Handles the logic for adding an item to the cart. */ -(void) addToCart:(Item *)itemToAdd withColor:(ColorObject*)color andSize:(NSString*)size

andItemURL:(NSString*)url { self.totalItems++; NSString *itemKey = [self generateKey:itemToAdd withColor:color.colorName andSize:size]; self.total = [self.total decimalNumberByAdding:itemToAdd.price]]; if ([self.itemsInCart keyExists:itemKey]) { CartItem *cartItem = (CartItem*)[self.itemsInCart objectForKey:itemKey]; cartItem.quantity++; return; } CartItem *newItem = [[CartItem alloc] initWithItem:itemToAdd andSize:size

andColor:color andCartKey:itemKey andItemURL:url]; [self.itemsInCart addObject:newItem forKey:itemKey]; }

/*! * Handles the logic for deleting an item from the cart. */ -(void)deleteFromCart:(NSInteger)itemIndex { CartItem *itemToDelete = [self.itemsInCart objectAtIndex:itemIndex]; self.totalItems = self.totalItems - itemToDelete.quantity; NSDecimalNumber *totalToDelete = [itemToDelete.item.price

decimalNumberByMultiplyingBy:itemToDelete.quantity]; self.total = [self.total decimalNumberBySubtracting:totalToDelete]; [self.itemsInCart removeObjectForKey:itemToDelete.cartKey]; }

Push Notification Integration• Customer subscribes to notifications

on order updates after logging in • Visual notifications

• Alerts appear to inform employee of a new purchase

- (void) application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{

NSArray *tag = [NSArray arrayWithObjects:@"customerTag", nil]; IMFPushClient *pushService = [IMFPushClient sharedInstance]; pushService.environment = @"sandbox"; [pushService registerDeviceToken:deviceToken completionHandler:

^(IMFResponse *response, NSError *error) { if (nil != error){ NSLog(@"Error register device token with error: %@", error); } else { NSLog(@"Device has been registered with response: %@", response); [pushService subscribeToTags:tag completionHandler:

^(IMFResponse *response, NSError *error) { NSLog(@"Subscribed to tag with response: %@", response); }]; } }]; }

- (void)application:(UIApplication *)application didReceiveRemoteNotification: (NSDictionary *)userInfo

{ NSString *message = [[[userInfo valueForKey:@"aps"]

valueForKey:@"alert"] valueForKey:@"body"]; [UIApplication sharedApplication].applicationIconBadgeNumber =

[[[userInfo objectForKey:@"aps"] objectForKey:@"badgecount"] intValue]; [self showNotification:message]; if ([[[userInfo valueForKey:@"aps"] valueForKey:@"category"]

isEqualToString:@"PURCHASE_CHANGE"]){ if (application.applicationState == UIApplicationStateActive){ [[self notificationCenter] postNotificationName:@"Purchase_Change"

object:nil userInfo:userInfo]; [[PushService pushInstance] resetPushCounter]; } else if (application.applicationState == UIApplicationStateBackground

|| application.applicationState == UIApplicationStateInactive){ [[self notificationCenter] postNotificationName:@"Purchase_Change"

object:nil userInfo:userInfo]; [[PushService pushInstance] resetPushCounter]; } } }

• Notifies a customer if the status of her/his order has changed

• Data channel • Customers’ purchase statuses

are updated when the view is reloaded

• Full support for interactive notifications in iOS 8

• Uses tags and subscriptions to send targeted messages to customers

Location

• Device level APIs for obtaining user’s current location

• APIs map store locations in close proximity to the user

• User can denote preferred store location and obtain directions.

Weather Service

• Server side integration logic written in Node.js

• APIs get current weather for store locations using 3rd party weather service

Mobile Quality Assurance

• Admin dashboard on Bluemix • Pre-production or production

SDKs • Capture device metrics with

every bug report • Analyze errors by build, device,

etc.

MQA Dashboard

AcmeApparel

AcmeApparel

Mobile Analytics

• Operational Analytics catered to the mobile app developer

• Request metrics are automatically captured for the various Mobile Cloud Services

• Capture mobile OS levels • Analyze errors by build,

device, etc.

Data Analytics

Push Analytics

Security Analytics

DEMO

Thank You!Todd Kaplinger

@todkap

© 2015 IBM Corporation