Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Glympse Client SDK Overview


Published on

Among huge variety of interesting tech developed at Glympse here is an overview of our client SDK - cross-platform library powering numerous mobile applications in automotive, navigation and messaging areas.

Published in: Technology
  • Be the first to comment

Glympse Client SDK Overview

  1. 1. Client API Technology Behind Glympse-enabled Applications Copyright (c) 2016 Glympse, Inc. All Rights Reserved. Patents Pending Egor Pushkin Chief Architect Glympse, Inc.
  2. 2. Partners
  3. 3. Applications Street Pilot App Radio Verizon Messages for HERE for
  4. 4. Terminology Client API / API / Library / Platform class library encapsulating Glympse related functionality Client Application / Host Application / Application 3rd party Glympse-enabled application Device / Phone any device supported by Glympse API Glympse Services / REST API / Server Glympse cloud services Glympse / Ticket A location sharing activity on the system… Glympse © 2016 All Rights Reserved
  5. 5. Send a Glympse View a Glympse Glympse Request Glympse Groups "!" Fundamental Features Glympse Glympse Request Glympse !Group Sender Viewer Requester Viewer Sender Requestee Group Members Group Followers G lym pse Glympse Glympse Glympse © 2016 All Rights Reserved
  6. 6. API Highlights Extreme Level of Portability Common code base is shared across C++/Java/C# Supported Mobile Platforms Android, iOS, BlackBerry 10, Windows Phone 8 Common Public Interface and Documentation Public interfaces of all exposed objects are identical across all platforms Programming paradigms and patterns are identical across all platforms Component-oriented Architecture API functionality is splitted into independent components, which makes it extremely easy to extend and maintain library feature set Highly Customizable Most aspects of library behavior are configurable both locally and globally Glympse © 2016 All Rights Reserved
  7. 7. High-Level View Glympse API Public Interface Concurrency Mutex, Semaphore, Thread, Event Thread, Timer, Handler Core Strings, Containers Images NetworkingStorage Files, Cache, Keychain GPS Location, Proximity Battery Messaging Provider, Receiver Contacts CalendarDebug Device Info, Crash Reporting, Logging HAL Glympse Business Logic Config Server Interaction JSON Parser Image Cache Contacts Manager External Services Glympse REST API Search, Directions Groups Manager User Manager History Manager Battery Manager Accounts Manager Network Manager Location Manager Social Manager Directions Manager Notification Center Glympse Facade Portable Code Glympse © 2016 All Rights Reserved
  8. 8. Object Model Glympse User Manager User Ticket History Manager Place Message Invite Group Manager Image Network Manager Track Social Manager Network Transport Layer, Device APIs (location, persistence, etc.) Applications, Extensions Battery Manager Glympse © 2016 All Rights Reserved
  9. 9. Listener Eventing Model Sink IEventSink IEventListener 1 * Sink interfaces IGlympse INetworkManager ILocationManager IBatteryManager IUser ITicket IImage Event properties - Glympse platform instance - Listener type - Events mask - Parameter object event Glympse User Manager User Ticket Listener GE::LISTENER_PLATFORM GE::PLATFORM_USER_ADDED IUser GE::LISTENER_USER GE::USER_ACTIVE_TICKET_CHANGED IUser GE::LISTENER_TICKET GE::TICKET_TRACK_CHANGED ITicket 2 1 3 Glympse © 2016 All Rights Reserved
  11. 11. Federated Login Glympse Server 3rd-party Service Glympse Client API if ( !glympse.hasUserAccount() ) { GPrimitive profile = GlympseFactory. createFacebookAccountProfile(token); glympse.login(profile); } Login using 3rd-party account profile f / t Acquire 3rd-party [oAuth] token 1 Pass token to Glympse API 2 Create/get user account associated with the token 3 Validate the token and extract user identifier 4 Respond with status and requested details 5 Internal account lookup based on user ID in 3rd party service 6 Glympse user identity in the form of Glympse user ID and long-lived Glympse token 7 Access token Glympse © 2016 All Rights Reserved
  12. 12. API Lifecycle NOT STARTED STOPPED ACTIVE NOT ACTIVE IGlympse::start() IGlympse::stop()IGlympse::stop() IGlympse::setActive(false) IGlympse::setActive(true) GLYGlympse* glympse = [[GLYGlympse alloc] initWitServer:@”SERVER BASE URL” andApiKey:@"API KEY"]; [glympse raw]->start(); Instantiate and start Glympse platform Major platform states Glympse © 2016 All Rights Reserved
  13. 13. User Profile GUser user = [glympse raw]->getUserManager()->getSelf(); GString nickname = CoreFactory::createString(“Sylvia”); UIImage* avatarImage = [UIImage imageNamed:@"sylvia.jpg"]; GDrawable avatar = [GLYGlympse createDrawable:avatarImage]; user->modify(nickname, avatar); Set user nickname and avatar Local properties (persisted on device) - API configuration - Incoming tickets - Public groups - Social tokens - Favorites - Recents Global properties (synced with server) - Account credentials - Nickname - Avatar - Outgoing tickets Glympse © 2016 All Rights Reserved
  14. 14. Ticket Lifecycle Sender Ticket lifetime Invite 1 lifetime Invite 2 lifetime Ticket always expires naturally. No special data is sent from server to viewers upon expiration. Create ticket Create another invite Create invite Timeline 1 2 3 Viewer 1 Viewer 2 Ticket duration Pull updates Pull updates Viewer can only access ticket data within a window bounded by invite creation time and ticket expiration time (or invite removal time). Glympse © 2016 All Rights Reserved
  15. 15. Ticket Creation Ticket Invite Glympse Server Viewer Sender Create ticket1 Upload locations and data 5 Create invite(s)2 XXX-XXX Send invite over email, sms or PUSH 3.1 Send invite over sms 3.2 Pull updates4 Only one of 3.1 and 3.2 actually takes place. 4 and 5 go in parallel. Glympse in the Cloud Glympse © 2016 All Rights Reserved
  16. 16. Send a Ticket GTicket ticket = GlympseFactory::createTicket( 3600000, CoreFactory::createString("Going home!"), NULL); 1. Create ticket object GGlympse glympse = ...; glympse->sendTicket(ticket); GInvite invite = GlympseFactory::createInvite( GC::INVITE_TYPE_EMAIL, CoreFactory::createString(“Sylvia”), CoreFactory::createString(“”)); ticket->addInvite(invite); 2. Create and add invite 3. Send a ticket Glympse © 2016 All Rights Reserved
  17. 17. Supported Services Facebook Twitter Evernote Social Integration GPrimitive profile = GlympseFactory::createFacebookAccountProfile(...); glympse->getLinkedAccountsManager()->link( GC::LINKED_ACCOUNT_TYPE_FACEBOOK(), profile); GInvite invite = GlympseFactory::createInvite( GC::INVITE_TYPE_FACEBOOK, NULL, NULL); 2. Create ticket invite 1. Link required 3rd-party account (if not yet linked) ticket->addInvite(invite); glympse->sendTicket(ticket); 3. Send a ticket Glympse Server Facebook Graph API Glympse © 2016 All Rights Reserved
  18. 18. Expire On Arrival GConfig config = glympse->getConfig(); config->setExpireOnArrival(GC::EXPIRE_ON_ARRIVAL_AUTO); Modify global XoA preference Ticket Proximity Provider Glympse Location Manager History Manager GE::PLATFORM_TICKET_ARRIVED GE::LISTENER_PLATFORM GE::TICKET_ARRIVED GE::LISTENER_TICKET 5 Proximity event (region entered)1 Proximity notification GE::LOCATION_REGION_ENTERED2 Expire ticket. This only happens in GC:: EXPIRE_ON_ARRIVAL_AUTO mode.3 4 Mechanism above is only involved in GC:: EXPIRE_ON_ARRIVAL_AUTOand GC:: EXPIRE_ON_ARRIVAL_PROMPTmodes. Glympse © 2016 All Rights Reserved
  19. 19. Estimated Time of Arrival Glympse API Glympse Server Directions Service glympse->setEtaMode(GC::ETA_MODE_EXTERNAL); Enable manual ETA mode (default) Request ETA and predicted route n-1 Append new ETA to the ticketn+1 ticket->updateEta(NEW ETA IN MILLISECONDS); ticket->updateRoute(NEW ROUTE); n. Update ETA/route for the ticket Host Application Update ETAn It only makes sense to update ETA every 5 seconds or less, when user is moving OR each 30 otherwise. As for the route, the updates should be even less frequent taking amount of data that needs to be sent into account. Glympse © 2016 All Rights Reserved
  20. 20. Estimated Time of Arrival Glympse API Create ticket with destination and start uploading locations 1 Glympse Server Directions Service glympse->setEtaMode(GC::ETA_MODE_INTERNAL); Enable automatic ETA mode Request ETA and predicted route n Append new ETA and route (optional) to the ticket n+1 Ticket destination must be specified for Client APi to be able to calculate ETA automatically. Steps n and n+1 are repeated periodically during ticket lifetime. Host Application iOS, Android Activity Recognition unit or Device activity is detected automatically by the OS User's activity is determined by host application or explicitly specified by user Glympse © 2016 All Rights Reserved
  21. 21. Glympse Request Lifecycle RequesteeRequester Send ticket6 Create request - invite - duration - end time - message - destination 1 3 is potentially done by server. It depends on request delivery mechanism. Glympse Server Request code XXX-XXX 2 Send request invite XXX-XXX 3 Decode invite XXX-XXX 4 Request details - invite - duration - message - destination 5 Invite points back to requester Glympse © 2016 All Rights Reserved
  22. 22. GInvite requestInvite = GlympseFactory:: createInvite(Glympse::GC::INVITE_TYPE_EMAIL, Glympse::CoreFactory::createString(“Roger”), Glympse::CoreFactory::createString(“ ”)); requestInvite->setRequestTicket(requestTicket); GInvite selfInvite = GlympseFactory:: createInvite(Glympse::GC::INVITE_TYPE_EMAIL, Glympse::CoreFactory::createString(“Sylvia”), Glympse::CoreFactory::createString(“sylvia ”)); requestTicket-> addInvite(selfInvite); GTicket requestTicket = Glympse::GlympseFactory:: createTicket(3600000, NULL, NULL); Request a Ticket 5. Send a request 1. Create ticket to be requested 2. Create invite pointing to requester (self user) glympse-> requestTicket(ticketContainer); 3. Create invite pointing to requestee Sylvia requests a ticket from Roger 4. Create a container ticket GTicket ticketContainer = Glympse::GlympseFactory::createTicket(0, NULL, NULL); ticketContainer->addInvite(requestInvite); Glympse © 2016 All Rights Reserved
  23. 23. Anatomy of Glympse Invite glympse:?XXXX-XXXX Invite URI Invite types - Ticket invite - Request invite Client delivery mechanisms (3) - SMS (most devices) - Facebook - Twitter - Share (Android devices) - Clipboard (Android devices) - Link (custom method) Server delivery mechanisms (4) - Email - SMS (selective regions) - Glympse account - Facebook - Twitter - Group Sender Glympse Server Client side invite delivery3 Create invite of specific type1 Invite code and delivery status2 Receiver Server side invite delivery 4 Delivery status update3.1 OR Glympse server is always responsible for the generation of invite code, invite URI and even accompanying message text indifferently from invite type and delivery mechanism. Glympse © 2016 All Rights Reserved
  24. 24. IGlympse::decodeInvite(...) Supported decoding modes: GC::INVITE_MODE_DEFAULT GC::INVITE_MODE_PROMPT_BEFORE_VIEWING 1 Handling Invites See where I am: glympse.enableSmsScraping(true); Enable automatic SMS scraping (Android) Host Application Glympse API Invite delivered over SMS/Email/Push or user input 1 Invite scraped from SMS When invite code is scraped from SMS, Client API behaves as if IGlympse::decodeInviteis called in GC::INVITE_MODE_PROMPT_BEFORE_VIEWING mode IGlympse::decodeInvite(...) IGlympse::openUrl(...)2 Glympse Invite Sink 1.1 Returns GE::INVITE_DECODED OR GE::INVITE_INVALID_CODE GE::LISTENER_INVITE3 GE::PLATFORM_INVITE_TICKET OR GE::PLATFORM_INVITE_REQUEST GE::LISTENER_PLATFORM2 GE::PLATFORM_INVITE_TICKET event is only spread in GC::INVITE_MODE_PROMPT_BEFORE_VIEWING mode Glympse © 2016 All Rights Reserved
  25. 25. View a Glympse The following pattern of listening to object model events allows to keep track of all standalone incoming tickets Glympse User Manager User Ticket GE::TICKET_FIRST_VIEWED GE::TICKET_DURATION_CHANGED GE::TICKET_MESSAGE_CHANGED GE::TICKET_DESTINATION_CHANGED GE::TICKET_TRACK_CHANGED GE::TICKET_ETA_CHANGED GE::TICKET_ROUTE_CHANGED GE::TICKET_DATA_APPENDED GE::TICKET_EXPIRED GE::TICKET_INVALID_CODE GE::LISTENER_TICKET GE::USER_ACTIVE_TICKET_CHANGED GE::USER_TICKET_REMOVED GE::LISTENER_USER GE::PLATFORM_USER_ADDED GE::PLATFORM_USER_REMOVED GE::LISTENER_PLATFORM Subscribe on user events Subscribe on user's active ticket (if any) Unsubscribe from user events Unsubscribe from user's active ticket (if any) Subscribe events from new active ticket Unsubscribe from ticket events Handle ticket events in application specific manner Glympse © 2016 All Rights Reserved
  26. 26. Custom Ticket Properties History Manager Ticket Glympse Server User Ticket GE::TICKET_DATA_APPENDED GE::TICKET_DATA_CLEARED GE::LISTENER_TICKET ITicket::appendData(...) 1 2 int32 partnerId = PARTNER ID; GString name = CoreFactory::createString("mood"); GPrimitive value = CoreFactory::createPrimitive( CoreFactory::createString("good")); ticket->appendData(partnerId, name, value); if ( GE::LISTENER_TICKET == listener ) { if ( 0 != ( events & GE::TICKET_DATA_APPENDED ) ) { GDataEvent data = (GDataEvent)object; for ( GDataRow property :data->getProperties() ) { GDataRow property = data->getProperties()->at(i); GString mood = property->getValue()->getString(); } } } 1. Appending property to ticket 2. Handling custom properties Sender Viewer GTicket ticket = ...; int32 partnerId = PARTNER ID; GString name = CoreFactory::createString("mood"); GPrimitive property = ticket->getProperty(partnerId, name); GString mood = property->getString(); Glympse © 2016 All Rights Reserved
  27. 27. Public Group Concept User Group Manager Ticket Group Member Group Glympse History Manager Ticket Invite User Manager Glympse Server Group !group_name type: GC::INVITE_TYPE_GROUP address: !group_name Follower Member GE::LISTENER_GROUPS GE::GROUPS_GROUP_ADDED GE::GROUPS_GROUP_REMOVED GE::GROUP_FIRST_VIEWED GE::GROUP_ORDER_CHANGED GE::GROUP_MEMBER_ADDED GE::GROUP_MEMBER_REMOVED GE::GROUP_MEMBER_TICKET_RESIGNING GE::GROUP_MEMBER_TICKET_CHANGED GE::GROUP_INVALID_CODE GE::GROUP_FAILED GE::LISTENER_GROUP Glympse © 2016 All Rights Reserved
  28. 28. Sending to a Group GTicket ticket = GlympseFactory::createTicket( 3600000, CoreFactory::createString("Going home!"), NULL); 1. Create ticket object GGlympse glympse = ...; glympse->sendTicket(ticket); GInvite invite = GlympseFactory::createInvite( GC::INVITE_TYPE_GROUP, NULL, CoreFactory::createString(“!GROUP_NAME”)); ticket->addInvite(invite); 2. Create and add invite 3. Send a ticket Glympse © 2016 All Rights Reserved
  29. 29. Following a Group GGroupManager groupManager = glympse->getGroupManager(); groupManager->viewGroup( CoreFactory::createString("!GROUP_NAME")); Start following group via group name (starts with !) glympse->openUrl(CoreFactory::createString( "See where we are!GROUP_NAME"), GC::INVITE_MODE_DEFAULT, NULL); Start following group via message containing group URI This method helps to avoid message processing and eventually leads to GGroupManager::viewGroup(...). GConfig config = glympse->getConfig(); config->setAutoWatchPublicGroup(true); Enable automatic watching If this feature is enabled, Glympse API automatically starts watching a group, when ticket is sent to it. Glympse © 2016 All Rights Reserved
  30. 30. Location Profiles It is possible to apply different accuracy requirements to location provider based on system state. See ILocationManager and ILocationProfile for more details. Variable Post Rate Post rates (for different API states) are configurable on per API key basis. Customizable Location Provider Glympse API can consume location information from any source (potentially more battery efficient that standard location API provided by the OS). Battery Thresholds Glympse API is capable of shutting down most its activities, if device battery level falls below specified critical value (see IBatteryManager). Concurrent Networking Host application is notified, when Glympse API is about to initiate network activity, which allows to combine requests and minimize battery drain caused by antenna. Battery Saving Techniques Glympse © 2016 All Rights Reserved
  31. 31. Location Profiles LocationManager LocationProfile LocationProvider Glympse API HAL Host Application Enable profiles Internal events trigger profile switches Configure profile properties Apply profile Active Watching Foreground Active Not Watching Background Profiles and transitions Glympse © 2016 All Rights Reserved
  32. 32. Location Profiles Behavior Sender Timeline Optimized for battery consumption Start viewing ... ... GC::LOCATION_PROFILE_ACTIVE_NOT_WATCHED Provider: Network (or even none) Accuracy: 300m GC::LOCATION_PROFILE_ACTIVE_WATCHED Provider: Network and GPS Accuracy: Best Viewer Timeline Optimized for quality Location provider adjustment overheadCommunication overhead (including network latency) Glympse API switches between location profiles automatically. Host application only needs to specify actual profile properties. Glympse © 2016 All Rights Reserved
  33. 33. Location Usage has active tickets? is in the foreground? location disabled yes yes no is location requested explicitly? yes no IGlympse::setActive ILocationManager::startLocation ILocationManager::stopLocation no Is battery OK? noyes IBatteryManager::setBatteryLevels start are profiles enabled? location enabled Should provider be enabled? ILocationProfile::getMode no yes CC::LOCATION_MODE_DISABLEDCC::LOCATION_MODE_DEFAULT Set of rules for determining location provider state (enabled vs. disabled) Glympse © 2016 All Rights Reserved
  34. 34. Custom Location Provider Glympse Custom Location Source Host Application Specify custom provider Default Location Provider Location Manager Custom Location Provider Custom location source featuring high location quality, low battery consumption or both Custom location provider implements ILocationProvider. Standard Location API GLocationProvider customProvider =new CustomLocationProvider(); GLocationManager locationManager = glympse->getLocationManager(); locationManager->setLocationProvider(customProvider); Override default location provider Glympse © 2016 All Rights Reserved
  35. 35. Sibling Tickets History Manager Self Active Tickets Sibling Active Tickets Expired Tickets Sorting order among expired tickets is preserved based on expire time only (ticket ownership is ignored) ... ... ... 0 1 n GGlympse glympse = ...; glympse.allowSiblingTickets(true); Make sibling tickets visible History Manager ... ... ... 0 1 n Self Active Tickets Sibling Active Tickets Expired Tickets Process A Process B Glympse © 2016 All Rights Reserved
  36. 36. GoGo Overview Glympse API Location Provider WiFi Manager Flight Detector Ground Agent Tickets 1 Glympse in the cloud Tickets Flight details (tail number, destination) 2 Plane location for local (on device) purposes 2.1 [ optional ] Location updates are pulled from a partner 4 Platform finds itself on a plane Server populates inherited tickets with locations 5 Ticket ownership is passed to the ground agent 3 Transition happens transparently to viewers Viewing experience can be customized with airline branding Glympse © 2016 All Rights Reserved
  37. 37. GoGo Integration Glympse Handoff Manager Handoff Provider IHandoffManager IHandoffProvider Handoff functionality needs to be enabled for application API key in order for step 3 to succeed. Get user confirmation on populating location data without the need to keep device on. Is handoff available? IHandoffProvider:: isHandoffAvailable() no yes IHandoffProfile::allowHandoff()3 GE::LISTENER_HANDOFF GE::HANDOFF_PROVIDER_AVAILABLE1 2.1 2.2 Travel mode specifies the mode under which track points are generated: ITicket::getTravelMode() GE::TICKET_TRAVEL_MODE_CHANGED Ticket owner property provides some details on application currently responsible for appending location data: ITicket::getOwner() GE::TICKET_TRANSFERRED IGlympse Accompanying Ticket Properties Glympse © 2016 All Rights Reserved
  38. 38. Host Application OBD Location Location Plugins Glympse Platform OBD Location Provider OBD Location FlightAware Glympse Server Ticket ... OBD ID Location flow Workflow Legend Customer notification Platform can be configured to use external source of location data. Carrier service Glympse Infrastructure OBD Infrastructure Create a ticket and hand it off to specific OBD ID providing access credentials Sender Application Glympse © 2016 All Rights Reserved
  39. 39. Advanced Features Favorites Provides container for storing the most frequently used Glympses. Recents (recipients, messages, places) Collections of the most recently referred items. All these collections are automatically populated by Client API. Contacts Wrapper over standard contacts API providing some convenience helpers. Calendar Wrapper over standard calendar API. Authentication Provides access to Glympse user account information and ability to extend/modify standard authentication process. Glympse © 2016 All Rights Reserved
  40. 40. Debugging & Troubleshooting Crash Reporting Debug Logging API Helpers Object Model Explorer View a Glympse Tool Web API Explorer Remote Debugging Bots Simulator Glympse © 2016 All Rights Reserved
  41. 41. Infrastructure Production Sandbox Partner Properties API Key (required) - defines partner and is required to instantiate Glympse API Partner ID (optional) - required to append custom properties to tickets Brand (optional) - provides additional granularity level under API key Glympse Configuration GCM Sender ID (Android) - allows partner applications to be woken up by Glympse-initiated PUSH messages. Environment Glympse © 2016 All Rights Reserved
  42. 42. Partner Configuration Branded Viewer Experience Viewer experience can be customized based on either API key or Brand (or both) Custom Invite Text With localization support System Properties Maximum Glympse duration (default is 4 hours) Maximum active Glympses per user (default is 100) Maximum invites per Glympse (default is 100) Minimum interval between location points (default is 1 location per second) Adjustable post rate (for all library states) Glympse © 2016 All Rights Reserved