No, it doesn't seem that it is possible to get the timerID of the original InvokeTimerRequest
when handling an invocation in the Cascades APIs. Initially, I thought it might be possible to simply cast the InvokeRequest
to an InvokeTimerRequest
, but looking closely at the API definitions, these are separate classes and an InvokeTimerRequest
is fundamentally different than an InvokeRequest
.
An InvokeTimerRequest
basically registers a timer for generating an invocation to a specific target, and when/each time the timer fires, a new distinct InvokeRequest
object is created and sent. It is recommended to store the timerID when creating and registering the InvokeTimerRequest
, since the timerID must be used to de-register the invoke timer if it is recurring.
If you really need to get the ID of the request, and you are willing to go lower level, this might be possible using the BlackBerry Platform Services (BPS) API to handle invoke events. You would need to implement a BPS event loop in your service, and register to receive and handle navigator events. From the event you can retrieve the navigator_invoke_invocation_t
structure describing the invocation, and you should be able to call navigator_invoke_invocation_get_id()
to retrieve the ID of the InvokeRequest
.
switch (bps_event_get_code(event)) {
case NAVIGATOR_INVOKE_TARGET: {
const navigator_invoke_invocation_t *invoke =
navigator_invoke_event_get_invocation(event);
// an invocation has been received
if(invoke) {
// retrieve invocation action
QString action = navigator_invoke_invocation_get_action(invoke);
if (action.compare("bb.action.system.TIMER_FIRED") == 0) {
QString id = navigator_invoke_invocation_get_id(invoke);
}
}
}
break;
}
For a more C++ approach, you could create your own subclass of AbstractBpsEventHandler
to handle this instead.
However, in the end the ID retrieved is most likely only the ID of the generated InvokeRequest
, and not the timerID you specified when creating and registering the InvokeTimerRequest
.