I am trying to get user ID and session ID from Session Context and pass it back to the App but having difficulties. Anyone has experience with it?
There is a discrepancy between the two iOS and Android trackers.
We are working on putting more in sync the APIs of the two trackers. Further improvements can be introduced in the next versions of both.
Android tracker allows to access more informations about the session but, in general, our main trackers lets access userId and sessionIndex (not sessionId).
You have to access the session object and than get session Id and user Id:
String sessionId = tracker.getSession().getCurrentSessionId(); String userId = tracker.getSession().getUserId(); int sessionIndex = tracker.getSession().getSessionIndex();
You can get user Id directly from the tracker instance:
let tracker = <get here your tracker instance> let userId = tracker.getSessionUserId() let sessionIndex = tracker.getSessionIndex()
SPTracker *tracker = <get here your tracker instance> NSString *userId = [tracker getSessionUserId]; NSInteger sessionIndex = [tracker getSessionIndex];
There is no way to get the sessionId on iOS tracker, at the moment.
Thanks @Alex_Benini! It works, and it would be nice to have more similar structure of API across different platforms.
Also, just a side note for anyone doing it in React Native: Note that in React Native one have to use either callback or promise to get value into the app.