Geotrigger Service - Recent Proceedings · 2014-08-06 · •The Geotrigger API uses OAuth2 •...
Transcript of Geotrigger Service - Recent Proceedings · 2014-08-06 · •The Geotrigger API uses OAuth2 •...
Geotrigger Service Davy Stevenson, Kenichi Nakamura Esri R&D Center, Portland
Esri UC 2014 | Technical Workshop | Geotrigger Service
Overview
Esri UC 2014 | Technical Workshop | Geotrigger Service
GeoEvent Processor • On premise server appliance
• Can be installed behind firewalls
• Dedicated industrial-strength GPS
• Life or death? Choose GeoEvent Processor
Esri UC 2014 | Technical Workshop | Geotrigger Service
Geotrigger Service • Cloud-based
• Consumer-grade GPS
• Perfect for iOS and Android apps
Esri UC 2014 | Technical Workshop | Geotrigger Service
What could your app do if it knew where it was?
Esri UC 2014 | Technical Workshop | Geotrigger Service
What is a Geotrigger?
Esri UC 2014 | Technical Workshop | Geotrigger Service
What about Battery Drain?
Esri UC 2014 | Technical Workshop | Geotrigger Service
Increases power near content
Decreases power use away from
content
Esri UC 2014 | Technical Workshop | Geotrigger Service
Text Label Rough Mode
Least Battery Drain
Delayed Messaging
Esri UC 2014 | Technical Workshop | Geotrigger Service
Text Label Fine Mode
Most Battery Drain
Fastest Messaging
Esri UC 2014 | Technical Workshop | Geotrigger Service
Text Label Adaptive Mode
Less Drain
Fast Messaging
Esri UC 2014 | Technical Workshop | Geotrigger Service
Esri UC 2014 | Technical Workshop | Geotrigger Service
Use Cases
Esri UC 2014 | Technical Workshop | Geotrigger Service
This bridge will be closed on Saturday for a marathon!
Esri UC 2014 | Technical Workshop | Geotrigger Service
traffic ahead!
Esri UC 2014 | Technical Workshop | Geotrigger Service
New house for sale!
Esri UC 2014 | Technical Workshop | Geotrigger Service Esri UC 2014 | Technical Workshop | Geotrigger Service
Historic town hall, founded in 1897 on Capitol St.
Esri UC 2014 | Technical Workshop | Geotrigger Service
Esri UC 2014 | Technical Workshop | Geotrigger Service pdx.esri.com
Esri UC 2014 | Technical Workshop | Geotrigger Service
Getting Started
Esri UC 2014 | Technical Workshop | Geotrigger Service
Create an account at developers.arcgis.com/en/sign-up/ or log in if you
already have an account
Esri UC 2014 | Technical Workshop | Geotrigger Service
Create an application developers.arcgis.com/en/applications/
Esri UC 2014 | Technical Workshop | Geotrigger Service
Apple
• Go to your Apple Developer account to get a Push Certificate (iOS)
• Make sure the push cert has been set on your app and that your app is registered to handle push notifications
https://developer.apple.com/notifications/
Register for Push Notifications
Esri UC 2014 | Technical Workshop | Geotrigger Service
Register for Push Notifications Android
• Get a GCM key (Google)
• Make sure the GCM key is in the push notification settings for your app and that you have set your GCM sender ID when you initialize the Geotrigger Service.
developer.android.com/google/gcm/
Esri UC 2014 | Technical Workshop | Geotrigger Service
Test your Push Notifications!
Esri UC 2014 | Technical Workshop | Geotrigger Service
SDKs for iOS and Android Wraps native location services on
each platform
Provides a set of tracking profiles for low, medium, and high power consumption
Push Notification Handling
Esri UC 2014 | Technical Workshop | Geotrigger Service
SDK App Project
Esri UC 2014 | Technical Workshop | Geotrigger Service
Geotrigger SDK for iOS Get the SDK from Github or CocoaPods
• pod ‘GeotriggerSDK’
• Ensure your app has ‘Location Updates’ and ‘Background Fetch’ background modes enabled
• Call one of the setupWithClientId: methods
Esri UC 2014 | Technical Workshop | Geotrigger Service
Geotrigger SDK for Android Get the Sample App and SDK from GitHub:
• github.com/esri/geotrigger-sdk-android
• Change the package name in the sample app or add the required permissions to your existing AndroidManifest.xml
• Use the GeotriggerHelper to start the Geotrigger Service
Esri UC 2014 | Technical Workshop | Geotrigger Service
Test your triggers! • Create test triggers
• Walk around outside to test push notifications
• 100m radius minimum
Esri UC 2014 | Technical Workshop | Geotrigger Service
Geotrigger API • Manage devices,
triggers, and tags
• Access trigger history
• Build custom statistics
Esri UC 2014 | Technical Workshop | Geotrigger Service
• Location should be used to enhance
• Explain why you are using location in app description
• Be prepared for app rejection, so submit at least 2-3 weeks before you plan to launch
Submitting Your App to iTunes
Esri UC 2014 | Technical Workshop | Geotrigger Service
Geotrigger Service API
Esri UC 2014 | Technical Workshop | Geotrigger Service
Authentication • The Geotrigger API uses OAuth2
• Requests to the Geotrigger API require an access token
• To get an access token make a request with the client_id and client_secret to the “oauth2/token” endpoint of ArcGIS Online
• Devices register with ArcGIS Online using only the client_id, and are given a refresh token in addition to the access token.
Esri UC 2014 | Technical Workshop | Geotrigger Service
Triggers • Define what happens when someone enters or leaves a place
• Triggers have a location that can be a circle or a polygon (EsriJSON or GeoJSON)
• Date and time ranges can restrict when triggers are active
• Triggers can have a limit to the number of times they can be fired
Esri UC 2014 | Technical Workshop | Geotrigger Service
Tags • Used to associate triggers with devices
• Device must share a tag with a trigger to fire the trigger
• Example: Trigger labeled with ‘restaurant’ tag, user subscribes to ‘restaurant’ coupons.
Esri UC 2014 | Technical Workshop | Geotrigger Service
Geotrigger Editor
Esri UC 2014 | Technical Workshop | Geotrigger Service
Editor Overview • A visual interface for managing triggers
• List all triggers and filter by tag or trigger ID
• Create triggers by drawing trigger boundaries as circles and polygons
• Define and update trigger rules
Esri UC 2014 | Technical Workshop | Geotrigger Service
Geotrigger API Routes • /trigger/list
• /trigger/create
• /trigger/update
• /trigger/delete
Esri UC 2014 | Technical Workshop | Geotrigger Service
Geotrigger Editor: List View
Esri UC 2014 | Technical Workshop | Geotrigger Service
/trigger/list
{ "triggerIds": [...], "tags": [...], "geo": {...}, }
• List all triggers associated with an application
• All parameters are optional, used for filtering results:
Esri UC 2014 | Technical Workshop | Geotrigger Service
/trigger/list response { "triggers": [ { "triggerId": "portland_city_greeting", "condition": { ... }, "action": { ... }, "tags": [ ... ], } ], "boundingBox": { "xmin":-122.703123092651, "ymin":45.5058656770835, "xmax":-122.669820785522, "ymax":45.5359943919756, "spatialReference": {"wkid": 4326} } }
Esri UC 2014 | Technical Workshop | Geotrigger Service
Geotrigger Editor: Create/Update View
Esri UC 2014 | Technical Workshop | Geotrigger Service
Tags
Esri UC 2014 | Technical Workshop | Geotrigger Service
Condition
Esri UC 2014 | Technical Workshop | Geotrigger Service
Action
Esri UC 2014 | Technical Workshop | Geotrigger Service
Advanced Properties
Esri UC 2014 | Technical Workshop | Geotrigger Service
POST /trigger/create { "condition": { "direction": "enter", "geo": { "latitude": 45.5165, "longitude": -122.6764, "distance": 240 } }, "action": { "callbackUrl": "http://example.com/trigger", }, "setTags": ["office", "red", “blue”], }
Esri UC 2014 | Technical Workshop | Geotrigger Service
Advanced Trigger Properties • Trigger ID
• Custom IDs can be specified on create, but cannot be updated.
• Rate Limit • Number of seconds between executions, per device. Default 30. Set to 0 for no minimum.
• Times • Maximum number of executions, per device. Default 0 for no maximum.
• Properties • Arbitrary properties saved with the trigger.
Esri UC 2014 | Technical Workshop | Geotrigger Service
Advanced Trigger Properties There are more options not yet covered by the editor that you can access programmatically:
• boundingBox
• geoFormat
• fromTimestamp & toTimestamp
Esri UC 2014 | Technical Workshop | Geotrigger Service
POST /trigger/update { "triggerIds": [ ... ], "condition": { ... }, "action": { ... }, // to manage tags, you can use addTags, removeTags, or setTags "addTags": [ ... ], }
• Update multiple triggers by passing more than one ID in the triggerIds array, selecting by tag, or by geography
Esri UC 2014 | Technical Workshop | Geotrigger Service
Managing Tags • Manage tags using addTags, removeTags, and setTags
• addTags: array of tags to add to the set of current tags
• removeTags: array of tags to remove from set of current tags
• setTags: array of tags to replace the current set of tags
Esri UC 2014 | Technical Workshop | Geotrigger Service
Geotrigger Faker
Esri UC 2014 | Technical Workshop | Geotrigger Service
Faker Overview • A web application for sending location updates and
testing triggers
• Create a fake device or spoof an existing device
• Draw a point and radius to send location updates and fire triggers from the comfort of your workspace
Esri UC 2014 | Technical Workshop | Geotrigger Service
Geotrigger Faker: Sending Location Updates
Esri UC 2014 | Technical Workshop | Geotrigger Service
POST /location/update { "locations": [ { "latitude": 45.5194753769039, "longitude": -122.67609357921172, "accuracy": 55, "timestamp": "2014-03-11T17:07:24.727Z" } ], "previous": { "latitude": 45.51976103506265, "longitude": -122.67519235698273, "accuracy": 67, "timestamp": "2014-03-11T17:07:27.313Z" } }
Esri UC 2014 | Technical Workshop | Geotrigger Service
Callback Payload • JSON data that is sent to a callback URL when a trigger is fired
• Enable the callbackURL parameter within the trigger action.
• Can be used to create a customized app experience
Esri UC 2014 | Technical Workshop | Geotrigger Service
Callback Payload
{ "triggeredAt": { "iso8601": "2014-03-10T21:23:59.446+00:00", "unix": 1394486639 }, "trigger": { "triggerId": "Barista", "condition": { ... }, "action": { ... }, "times": 0, "rateLimit": 0, "tags": [...] }, "device": { "deviceId": “wKZsNENYcw5saINT", "tags": [...] }, "location": { "latitude": 45.519767717082, "longitude": -122.67545700116897, "accuracy": 17, "trackingProfile": "adaptive", "timestamp": "2014-03-10T21:23:54.592+00:00" } }
Esri UC 2014 | Technical Workshop | Geotrigger Service
Custom Notifications • API provides a way to send a notification to a device
• Can be used with callback payload to send customized push notifications
• Target devices by ID, geography or tag
Esri UC 2014 | Technical Workshop | Geotrigger Service
POST /device/notify // request { "tags": ["red"], "text": “Welcome Red Team!", "data": {"foo": “bar"} } // response {"devices": [ {"3XgGh30aTlEKlK91": "queued"}, {"8907123u9yasdjkn": “queued"}] }
Esri UC 2014 | Technical Workshop | Geotrigger Service
Demo
Esri UC 2014 | Technical Workshop | Geotrigger Service
Full Documentation https://developers.arcgis.com/geotrigger-service/
Getting Started, iOS & Android Setup, API Reference, SDK Reference, Developer Tools (Editor & Faker)
Esri UC 2014 | Technical Workshop | Geotrigger Service
Open Source • Geotrigger Editor & Geotrigger Faker are open source
• github.com/esri/geotrigger-editor • github.com/esri/geotrigger-faker
• Client Libraries in various languages:
• github.com/esri/geotrigger-js • github.com/esri/geotrigger-ruby • github.com/esri/geotrigger-go • github.com/esri/geotrigger-python
Esri UC 2014 | Technical Workshop | Geotrigger Service
Summary
Esri UC 2014 | Technical Workshop | Geotrigger Service
Test Outside • Create Triggers
• Take device out in real world
• Take laptop too!
• Use Geotrigger Editor & Geotrigger Faker to dynamically modify shape & size of triggers and to test location updates
• Start out with large triggers
Esri UC 2014 | Technical Workshop | Geotrigger Service
Developer Friendly • Easy for iOS and Android developers to use.
• Drop into existing app
• Build new app
• Support other platforms by using location/update
Esri UC 2014 | Technical Workshop | Geotrigger Service
What’s Next? Offline triggers
Feature Service integration
Configurable Solutions
Esri UC 2014 | Technical Workshop | Geotrigger Service
Thank You!
Please fill out the session survey: First Offering ID: 1155 Online - www.esri.com/ucsessionsurveys Paper - pick up an put in drop box
Esri UC 2014 | Technical Workshop | Geotrigger Service