Question
When working with the Tizen Message API, I'm experiencing a delay between when an SMS is received (and appears in the inbox) and when the message callback is triggered. The callback sometimes takes several minutes to fire. Is this an issue with my application or the Tizen OS?
Answer
Problem Understanding
The user is developing a native Tizen application that needs to process incoming SMS messages immediately. While messages appear in the inbox promptly, the Message API callback experiences significant latency (several minutes) before being triggered.
Solution Methods
-
Service Application Approach:
- For reliable SMS processing, implement as a service application rather than a UI application
- Enable background network support in the manifest
- This ensures the callback triggers promptly regardless of the app's foreground state
-
Manifest Configuration:
- Add background-category with network support
- Include necessary privileges for message reading
-
Callback Implementation:
- Properly initialize the message service
- Implement the message received callback to handle incoming messages
Code Examples
// Service initialization
messages_service_h msg_service = NULL;
messages_open_service(&msg_service);
messages_set_message_incoming_cb(msg_service, on_message_received, NULL);
// Callback implementation
void on_message_received(messages_message_h incoming_msg, void *user_data) {
char *message_txt = NULL;
if(messages_get_text(incoming_msg, &message_txt) == MESSAGES_ERROR_NONE) {
dlog_print(DLOG_DEBUG, LOG_TAG, "Message Text: %s", message_txt);
// Process message here
}
free(message_txt);
}
<!-- Manifest configuration -->
<service-application appid="org.example.smsservice" exec="smsservice" multiple="false" nodisplay="true" taskmanage="false" type="capp">
<background-category value="background-network"/>
</service-application>
<privileges>
<privilege>http://tizen.org/privilege/message.read</privilege>
</privileges>
Additional Tips
- This solution works on Tizen 2.3 and later versions
- For UI applications, consider implementing a hybrid approach with a service component
- Test thoroughly with different message types and network conditions
- Monitor battery usage as background network operations can impact power consumption