Transcript
Page 1: Integrating Clouds & Humans with Wearable Apps

Integrating Clouds & Humans with Wearable Apps

@_JamesWard Salesforce.com

Page 2: Integrating Clouds & Humans with Wearable Apps
Page 3: Integrating Clouds & Humans with Wearable Apps

Salesforce Wear Developer Packs

• Six Open Source Developer Packs developer.salesforce.com/wear

• Android Wear, Google Glass, Pebble, Samsung Gear, Myo, Nymi

• Getting Started Guides, Sample Apps, and architecture overviews

Page 4: Integrating Clouds & Humans with Wearable Apps

Android Wear• Android-based Wearable SDK

developer.android.com/wear

• Wearables as companions to Android Phones

• Glanceable notifications & interactions

• Phones push to wearables

• Moto360 & LG G

Page 5: Integrating Clouds & Humans with Wearable Apps

Salesforce Wear Developer Pack for Android Wear

• Quote Discount Approval Sample

• Native Android Phone App

• Salesforce Mobile Push

• Gradle Build

Page 6: Integrating Clouds & Humans with Wearable Apps

Sample: Quote Discount ApprovalSales Rep

Discount >= 20%

trigger QuoteApproval on Quote (before insert, before update) {

Page 7: Integrating Clouds & Humans with Wearable Apps

One beautiful Gradle build does everything (almost)

• Salesforce Metadata Deploy

$ ./gradlew forceMetadataDeploy

• Dependency Management

dependencies { compile "com.force:SalesforceSDK:2.1.1-3" compile "com.android.support:support-v4:19.+" compile files("libs/wearable-preview-support.jar") }

• Builds & runs the app

$ ./gradlew installDebug

Page 8: Integrating Clouds & Humans with Wearable Apps

Architecture• Salesforce

• Quotes on Opportunities

• Approval Workflow: Quote with Discount >= 20% requires approval from manager

• Trigger on Quote update/insert: creates approval process & sends mobile push message

• Android Phone App

• Receives push message

• Creates notification on watch

• Handles watch actions (Approve, Reject, Open)

Page 9: Integrating Clouds & Humans with Wearable Apps

Code Highlights - TriggerMessaging.PushNotification msg = new Messaging.PushNotification();

!Map<String, Object> payload = new Map<String, Object>();

payload.put('ownerName', owner.Name);

...

msg.setPayload(payload);

!String userId = result.actorIds[0];

Set<String> users = new Set<String>();

users.add(userId);

!msg.send('QuoteDiscountApproval', users);

Page 10: Integrating Clouds & Humans with Wearable Apps

Code Highlights - Push Receiver

public class QPN implements PushNotificationInterface { ! @Override public void onPushMessageReceived(final Bundle bundle) { ! final QM quoteMessage = new QM(bundle); ! ... } !} !!SalesforceSDKManager.getInstance() .setPushNotificationReceiver(new QPM(this));

Page 11: Integrating Clouds & Humans with Wearable Apps

Code Highlights - Wear Notification

WearableNotifications.Builder wearableBuilder = new WearableNotifications.Builder(mainNotification); !wearableBuilder .addPage(detailNotification) .addAction(rejectAction); !mainNotification .setContentIntent(openPendingIntent); !NotificationManagerCompat.from(context) .notify(1, wearableBuilder.build());

Page 12: Integrating Clouds & Humans with Wearable Apps

Code Highlights - Approve or Reject

JSONObject approvalRequest = new JSONObject(); approvalRequest.put("actionType", action); approvalRequest.put("contextId", workItemId); approvalRequest.put("comments", comments); !JSONArray requests = new JSONArray(); requests.put(approvalRequest); !JSONObject json = new JSONObject(); json.put("requests", requests); !StringEntity entity = new StringEntity(json.toString(), HTTP.UTF_8); entity.setContentType("application/json"); !String url = "/services/data/" + c.getString(R.string.api_version) + "/process/approvals/"; !final RestRequest restRequest = new RestRequest(RestRequest.RestMethod.POST, url, entity); !QuoteDiscountApprovalSetup.client.sendAsync(restRequest, new RestClient.AsyncRequestCallback() { @Override public void onSuccess(RestRequest request, RestResponse result) { } ! @Override public void onError(Exception exception) { } } );

Page 13: Integrating Clouds & Humans with Wearable Apps

https://github.com/developerforce/

WearablePack-AndroidWear


Recommended