Nonstop Brightscript SDK
Users
Login
login should be called whenever a user registers or signs in via OneID, after the call to create or update the user in ShowMS.
Thus the flow is:
OneID Success -> ShowMS Success -> Nonstop Success -> Control Returned to Client
The login function accepts the following parameters:
workflowListener- This should be an instance of anAssociativeArrayListener(a type also included within the SDK) which contains a field nameddatawhich can be observed and will be triggered once the SDK has finished the work of logging the user inuserDetails- This should contain the user's details.firstName- Should be the user's first name as returned by OneIDexternalId- Should be the user's ShowMS User IDemail- The email address for the user returned from OneID. This will be securely hashed and used to find the user in the admin for customer service scenarios.birthday- The user's birthday as returned from OneID in the formatYYYY-MM-DDswid- The user's SWID as returned by OneID
Note that externalId is a required field however, all other fields are optional. If values are available they should be supplied; if they are not available, there is no issue with omitting them.
The login function can then be called as follows:
sub OnLogin()
listener = createNodeAndInit("AssociativeArrayListener")
m.global.Nonstop.login.callFunc("start", {
workflowListener: listener,
userDetails: {
firstName: "Dave"
externalId: "showms-user-id"
email: "dave@stormideas.com"
birthday: "1988-01-19"
swid: "{a0d424b0-5176-4864-ae21-e8d43274a5a9}"
}
})
listener.observeFieldScoped("data", "onWorkflowListenerEvent")
end sub
function onWorkflowListenerEvent(message as object)
listener = message.getRoSGNode()
if listener.status = "complete" then
' Nonstop user successfully logged in
else if listener.status = "error" then
' Error logging in Nonstop user
end if
listener.unObserveFieldScoped("data")
end function
If the user should gain a reward by logging in then the SDK will play the appropriate animation before handing control back to the calling app.
Note: You can optionally pass an additional parameter:
m.global.Nonstop.login.callFunc("start", {
workflowListener: listener,
userDetails: {
firstName: "Dave"
externalId: "showms-user-id"
email: "dave@stormideas.com"
birthday: "1988-01-19"
swid: "{a0d424b0-5176-4864-ae21-e8d43274a5a9}"
}
suppressAnimation: true
})
To suppress any Reward Animation as a result of login. The main use case is when already logged in existing users need to be logged into Nonstop in the background as part of the upgrade path.
On error, the client should message the user and offer to retry.
The createdUser object returned with Success will have details of the logged in user's:
id- This is the externalId supplied in the login callname- The user's name as suppled in the login callpoints- The current number of points the user hasisNew- A bool indicating whether the user has used Nonstop before (e.g. on another platform) or whether this is their first time using Nonstop. This can be used to trigger UI or messaging changes as appropriate.
But there should be no need to store this on the client app.
While logged in the current user can be accessed via the SDK at all times via:
Is Connected
You can ask whether there is a currently logged in user via:
m.global.Nonstop.instance.callFunc("isConnected")
This should be used for Session Management scenarios.
Current User
You can access the currently logged in User via:
m.global.Nonstop.instance.callFunc("currentUser")
Logout
logout should be called whenever a user logs out of OneID.
m.global.Nonstop.instance.callFunc("logout")