In 2.2.243 version of the SDK incoming tags processing was added. It supports both online and offline modes. All tags will be uploaded with the specified time when they were made.
Methods doesn’t return any data. You can register a TagsProcessingListener or TagsProcessingReceiver (it is a BroadcastReceiver you have to implement on your side and register with the SDK) for subscribing to tags processing updates.
Methods for managing:
/** * Get tags * * The result of the operation you can get through the registration of [TagsProcessingListener] or [TagsProcessingReceiver]. * Check [registerTagsReceiver] and [addTagsProcessingCallback] * * @throwsIllegalStateException if [initialize] never called. See also [isInitialized]. */fungetFutureTrackTags()/** * Create new tag * * The result of the operation you can get through the registration of [TagsProcessingListener] or [TagsProcessingReceiver]. * Check [registerTagsReceiver] and [addTagsProcessingCallback] * @param tag tag's name * @param source source of the tag. Optional parameter * * @throwsIllegalStateException if [initialize] never called. See also [isInitialized]. */funaddFutureTrackTag(tag: String?, source: String? =null)/** * Remove specified tag * * The result of the operation you can get through the registration of [TagsProcessingListener] or [TagsProcessingReceiver]. * Check [registerTagsReceiver] and [addTagsProcessingCallback] * @param tag tag's name * * @throwsIllegalStateException if [initialize] never called. See also [isInitialized]. */funremoveFutureTrackTag(tag: String?)/** * Remove all tags. * * The result of the operation you can get through the registration of [TagsProcessingListener] or [TagsProcessingReceiver]. * Check [registerTagsReceiver] and [addTagsProcessingCallback] * * @throwsIllegalStateException if [initialize] was never called. See also [isInitialized]. */funremoveAllFutureTrackTags()
TagsProcessingListener
It has inside 4 methods:
onTagAdd(tag: Tag, activationTime: Long, status: Status) - callback of the addFutureTrackTag method
Parameters:
1. tag - Tag instance for adding
2. activationTime - UNIX-timestamp in milliseconds of the tag activation time
3. status - Status of the operation. Status can be:
Status.SUCCESS when tag was successfully uploaded to server
Status.OFFLINE when tag wasn’t uploaded to server (no internet, etc.), but will be sent later (when internet connection will appears)
Status.ERROR_TAG_OPERATION when operation can’t be proceeded on server because tag was already created earlier
Status.ERROR_WRONG_TIME when user sent wrong tme (future)
Status.ERROR_INVALID_TAG_SPECIFIED when tag name is null or empty
onTagRemove(tag: Tag, deactivationTime: Long, status: Status) - callback of the removeFutureTrackTag method
Parameters:
1. tag - Tag instance for removing
2. deactivationTime - UNIX-timestamp in milliseconds of the tag deactivation time
3. status - Status of the operation. Status can be:
Status.SUCCESS when tag was successfully removed from server
Status.OFFLINE when operation wasn’t pushed to server (no internet, etc.), but will be sent later (when internet connection will appears)
Status.ERROR_TAG_OPERATION when operation can’t be proceeded on server because tag wasn’t exist
Status.ERROR_WRONG_TIME when user sent wrong tme (future)
Status.ERROR_INVALID_TAG_SPECIFIED when tag name is null or empty
onAllTagsRemove(deactivatedTagsCount: Int, time: Long, status: Status)- callback of the removeAllFutureTrackTags method
Parameters:
1. deactivatedTagsCount - deactivated tags amount
2. time - UNIX-timestamp in milliseconds (time of the operation)
3. status - Status of the operation. Status can be:
Status.SUCCESS "Remove all tags" request was successfully proceeded
Status.OFFLINE when operation wasn’t pushed to server (no internet, etc.), but will be sent later (when internet connection will appears)
Status.ERROR_TAG_OPERATION when operation can’t be proceeded on server
Status.ERROR_WRONG_TIME when user sent wrong tme (future)
onGetTags(tags: Array<Tag>?, time: Long, status: Status)- callback of the getFutureTrackTags method
Parameters:
1. tags - Array<Tag>? - array of tags. Can be null if status in not SUCCESS
2. time - UNIX-timestamp in milliseconds (time of the operation)
3.status - Status of the operation. Status can be:
Status.SUCCESS - success
Status.OFFLINE if there is no internet connection
Sample of using TagsProcessingListener
Implement it on your side
val listener =object : TagsProcessingListener {overridefunonTagAdd(status: Status, tag: Tag, activationTime: Long) {runOnUiThread {when (status) { Status.SUCCESS -> {// tag successfully added } Status.OFFLINE -> {// tag was saved to the local storage. It will be sent later when internet will be available } Status.ERROR_TAG_OPERATION -> {// unable to add tag to server (The tag has already been created) } Status.ERROR_WRONG_TIME -> {// Unable to perform operation. Future time specified. } Status.ERROR_INVALID_TAG_SPECIFIED -> {// null or blank tag name specified } } } }overridefunonTagRemove(status: Status, tag: Tag, deactivationTime: Long) {runOnUiThread {when (status) { Status.SUCCESS -> {// tag was successfully removed } Status.OFFLINE -> {// tag deactivation was saved to the local storage. It will be sent later when internet will be available } Status.ERROR_TAG_OPERATION -> {// unable to add tag to server (Tag doesn't exist. Unable to remove) } Status.ERROR_WRONG_TIME -> {// Unable to perform operation. Future time specified. } Status.ERROR_INVALID_TAG_SPECIFIED -> {// null or blank tag name specified } } } }overridefunonAllTagsRemove(status: Status, deactivatedTagsCount: Int, time: Long) {runOnUiThread {when (status) { Status.SUCCESS -> {// "Remove all tags" request was successfully proceeded } Status.OFFLINE -> {// "Remove all tags" request was saved to the local storage. It will be sent later when internet will be available } Status.ERROR_TAG_OPERATION -> {// unable to proceed on server } Status.ERROR_WRONG_TIME -> {// Unable to perform operation. Future time specified. } } } }overridefunonGetTags(status: Status, tags: Array<Tag>?, time: Long) {runOnUiThread {when (status) { Status.SUCCESS -> {// all cached requests (for add/ remove/ remove all tags) were proceeded and tags fetched successfully } Status.OFFLINE {// can't fetch tags list. Try again later } } } }}
TagsProcessingReceiver works the same as TagsProcessingListener . But it's a BroadcastReceiver.
Methods are the same at all.
Sample of usingTagsProcessingReceiver
Add the following class to your application
classTagsReceiver : TagsProcessingReceiver() {overridefunonTagAdd(status: Status, tag: Tag, activationTime: Long) {when (status) { Status.SUCCESS -> {// tag successfully added } Status.OFFLINE -> {// tag was saved to the local storage. It will be sent later when internet will be available } Status.ERROR_TAG_OPERATION -> {// unable to add tag to server (The tag has already been created) } Status.ERROR_WRONG_TIME -> {// Unable to perform operation. Future time specified. } Status.ERROR_INVALID_TAG_SPECIFIED -> {// null or blank tag name specified } } }overridefunonTagRemove(status: Status, tag: Tag, deactivationTime: Long) {when (status) { Status.SUCCESS -> {// tag was successfully removed } Status.OFFLINE -> {// tag deactivation was saved to the local storage. It will be sent later when internet will be available } Status.ERROR_TAG_OPERATION -> {// unable to add tag to server (Tag doesn't exist. Unable to remove) } Status.ERROR_WRONG_TIME -> {// Unable to perform operation. Future time specified. } Status.ERROR_INVALID_TAG_SPECIFIED -> {// null or blank tag name specified } } }overridefunonAllTagsRemove(status: Status, deactivatedTagsCount: Int, time: Long) {when (status) { Status.SUCCESS -> {// "Remove all tags" request was successfully proceeded } Status.OFFLINE -> {// "Remove all tags" request was saved to the local storage. It will be sent later when internet will be available } Status.ERROR_TAG_OPERATION -> {// unable to proceed on server } Status.ERROR_WRONG_TIME -> {// Unable to perform operation. Future time specified. } } }overridefunonGetTags(status: Status, tags: Array<Tag>?, time: Long) {when(status) { Status.SUCCESS -> {// all cached requests (for add/ remove/ remove all tags) were proceeded and tags fetched successfully } Status.OFFLINE -> {// can't fetch tags list. Try again later } } }}
2. Add this broadcast receiver to the manifest before the </application> tag.