CSUserSession

@interface CSUserSession : CSSession
  This class is the heart of the transmit application. Once the session is created with the usageToken
  you can identify the user to the session by setting the trackingIdentifier and then be able to start/complete/cancel trips to different
  sites which are predefined on the ARRIVE platform.
  •   The sites which can be currently (at the time of the call) notified that the user has arrived at the site.
    

    Declaration

    Objective-C

    @property (readonly, nonatomic)
        NSSet<CSSite *> *_Nonnull sitesToNotifyMonitoringSessionUserOfArrival;

    Swift

    var sitesToNotifyMonitoringSessionUserOfArrival: Set<CSSite> { get }
  • The delegate object for the CSUserSession.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable) id<CSUserSessionDelegate>
        delegate;

    Swift

    var delegate: CSUserSessionDelegate? { get set }
  • This returns all the currently tracked CSSite(s) for the signed in user.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSSet<CSSite *> *_Nonnull trackedSites;

    Swift

    var trackedSites: Set<CSSite> { get }
  •   Consumers should be using this method to create a new session with their usageToken. The state of the session
      can be checked using the sessionState property. The delegate is also notified of sessionState changes  by the
      delegate callback.
    
      Note: The usage token is scoped to the Production and Sandbox. Make sure to use the production usage token when deploying
      your app to the Apple App Store.
    

    Declaration

    Objective-C

    + (nonnull instancetype)
    createSessionWithUsageToken:(nonnull NSString *)usageToken
                       delegate:(nullable id<CSUserSessionDelegate>)delegate;

    Swift

    class func createSession(withUsageToken usageToken: String, delegate: CSUserSessionDelegate?) -> Self
  •   This method returns the CSUserSession initialized by createSessionWithUsageToken:delegate:.
    

    Declaration

    Objective-C

    + (nonnull instancetype)currentSession;

    Swift

    class func current() -> Self
  • Call this method to notify the user in the CSMonitoringSession of the arrival of this user at the site.

    Declaration

    Objective-C

    - (void)notifyMonitoringSessionUserOfArrivalAtSite:(nonnull CSSite *)site;

    Swift

    func notifyMonitoringSessionUserOfArrival(at site: CSSite)
  •   Start a trip tracking the user to the site identified by the siteID. Call this method when
      the application thinks its appropriate to start tracking the user eg. Order is ready to be picked up at
      the site. This information is persisted across relaunch.
    
      If an error occurs because of an invalid session state, permissions or authentication with the ARRIVE server,
      the CSUserSessionDelegate will be informed with the reason as to why startTripToSiteWithIdentifier: failed.
    

    Declaration

    Objective-C

    - (void)startTripToSiteWithIdentifier:(nonnull NSString *)siteID
                               trackToken:(nonnull NSString *)trackToken;

    Swift

    func startTripToSite(withIdentifier siteID: String, trackToken: String)
  •   Start a trip tracking the user to the site identified by the siteID for the user's intent of arrival at a given time or a time window.
      Call this method when the application thinks its appropriate to start tracking the user.
    
      If the user's intent is to arrive at the site at a given time, then populate the fromDate with the arrival time. e.g. Pick up 
      a order at 6.00pm. Set the fromDate to be 6.00pm
    
      If the user's intent is to arrive at the site at a given time window, then populate the fromDate and toDate with the time window.
    
      If an error occurs because of an invalid session state, permissions or authentication with the ARRIVE server,
      the CSUserSessionDelegate will be informed with the reason as to why startTripToSiteWithIdentifier: failed.
    

    Declaration

    Objective-C

    - (void)startTripToSiteWithIdentifier:(nonnull NSString *)siteID
                               trackToken:(nonnull NSString *)trackToken
                              etaFromDate:(nonnull NSDate *)fromDate
                                   toDate:(nullable NSDate *)toDate;

    Swift

    func startTripToSite(withIdentifier siteID: String, trackToken: String, etaFrom fromDate: Date, to toDate: Date?)
  •   Completes the trip for the user to the site identified by the siteID with the given trackToken.
       If no trackToken is specified, then *all*   trips to this site  will be completed.
    
      - note: Do not call this when the user logs out, instead set the trackingIdentifier to nil when the user logs out.
    

    Declaration

    Objective-C

    - (void)completeTripToSiteWithIdentifier:(nonnull NSString *)siteID
                                  trackToken:(nullable NSString *)trackToken;

    Swift

    func completeTripToSite(withIdentifier siteID: String, trackToken: String?)
  •   This method would complete all trips for this user across all devices.
    
      - note: Do not call this when the user logs out, instead set the trackingIdentifier to nil when the user logs out.
    

    Declaration

    Objective-C

    - (void)completeAllTrips;

    Swift

    func completeAllTrips()
  •   Cancels the trip for the user to the given site identified by the siteID with the given trackToken. 
      If no trackToken is set, then *all* trips to this site are cancelled.
    
      - note: Do not call this when the user logs out, instead set the trackingIdentifier to nil when the user logs out.
    

    Declaration

    Objective-C

    - (void)cancelTripToSiteWithIdentifier:(nonnull NSString *)siteID
                                trackToken:(nullable NSString *)trackToken;

    Swift

    func cancelTripToSite(withIdentifier siteID: String, trackToken: String?)
  •   This method will cancels all trips for all sites for the user.
    
      - note: Do not call this when the user logs out, instead set the trackingIdentifier to nil when the user logs out.
    

    Declaration

    Objective-C

    - (void)cancelAllTrips;

    Swift

    func cancelAllTrips()
  • This method would update the ARRIVE SDK with the current state of tracked trips for the user from the server.

    Declaration

    Objective-C

    - (void)updateTripsFromServer;

    Swift

    func updateTripsFromServer()
  • This method will calculate the estimated time of arrival to a site. Negative value means ETA is unknown. Unit : seconds

    Declaration

    Objective-C

    - (void)etaToSiteWithIdentifier:(nonnull NSString *)siteID
                       fromLocation:(nonnull CLLocation *)fromLocation
                 transportationMode:(CSTransportationMode)transportationMode
                  completionHandler:(nonnull void (^)(int))completionHandler;

    Swift

    func etaToSite(withIdentifier siteID: String, from fromLocation: CLLocation, transportationMode: CSTransportationMode, completionHandler: @escaping (Int32) -> Void)
  •   This method simulates a mock trip to the site. It does the following :
          - startTripToSiteWithIdentifier: with the given site
          - Gets a route from the given startLocation to the site
          - Sends up the location on the route to the site at regular intervals to ARRIVE Server
    
      - note: You must cancel the trip using cancelMockTrip, once you are done. You can only do one Mock trip at a time.
    

    Declaration

    Objective-C

    - (void)startMockTripToSiteWithIdentifier:(nonnull NSString *)siteID
                                 fromLocation:(nonnull CLLocation *)startLocation;

    Swift

    func startMockTripToSite(withIdentifier siteID: String, from startLocation: CLLocation)
  •   This method cancels the mock trip started by the startMockTripToSite:fromLocation: method
    
      - note: You must call this method if you have started a MockTrip using startMockTripToSiteWithIdentifier:fromLocation:
    

    Declaration

    Objective-C

    - (void)cancelMockTrip;

    Swift

    func cancelMockTrip()