언어 설정

Menu
Sites
Language
SMS parsing
Hi everyone. When i am trying to work with message api , i found that sms is received and showing in my inbox, but msg api is not fired. that means my app get the sms body after a few minutes. is that the problem of my app or tizen os??

Responses

7 댓글
Shaswati Saha

Please share the souce code here.

Mahabub Zoraf
#include messages_service_h iMSH; void message_received_callback(messages_message_h incoming_msg, void *user_data){ //do something } int set_message_incoming_listener(){ int ret=messages_set_message_incoming_cb(iMSH, message_received_callback, NULL); } When a message is received , message_received_callback should be invoke. Actually message_received_callback method invoked. But it takes time to invoke after the message arrived. My problem is why message_received_callback method takes time to invoke?? And what can i do to remove this time latency???
Shaswati Saha

In which type of Tizen application you're trying to do this? Is it an UI app? According to my findings it's not suitable to use this functionality in an UI app. I would like to suggest you to write a service app with background support(enabling background-network in Background category) in this scenario.


I'm sharing my findings here. At first I tried it with an UI app. In this case, the problem is, incoming message doesn't show whenever my UI app is not in foreground(UI app remains closed). And if I open the UI app after sometime, it doesn't show the message even after waiting for 3 - 4 minutes, that means once it's missed receiving the message it's missed forever. As this behavior isn't supposed to be expected, I tried with a service app(enabling background support). In this case, it isn't creating any type of latency problem for me.

Note: I didn't face any type of latency problem in the case of UI app also.

Mahabub Zoraf
I am trying to make a native app. If possible, please share your code. it will be helpful for me. Thanks In Advance
Shaswati Saha

I've written the lines of code in the service_app_create() function.

messages_service_h msg_service = NULL;
messages_open_service(&msg_service);
messages_set_message_incoming_cb(msg_service, on_message_received, NULL);

And the  on_message_received() callback is written as below:

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): %s", message_txt);
	}
	free(message_txt);
}

Don't forget to add the line below in the tizen-manifest.xml file.

<background-category value="background-network"/>

 Hope, it'll be helpful!

Mahabub Zoraf
I am currently working on Tizen 2.3 and background-category does not support on Tizen 2.3. Any other solution do you have that may help me??
Shaswati Saha

Just add the below line

<background-category value="background-network"/>

 in the manifest file like this.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<manifest xmlns="http://tizen.org/ns/packages" api-version="2.3" package="org.example.servicebgsupport" version="1.0.0">
    <profile name="mobile"/>
    <service-application appid="org.example.servicebgsupport" exec="servicebgsupport" multiple="false" nodisplay="true" taskmanage="false" type="capp">
        <label>servicebgsupport</label>
        <icon>servicebgsupport.png</icon>
        <background-category value="background-network"/>
    </service-application>
    <privileges>
        <privilege>http://tizen.org/privilege/message.read</privilege>
    </privileges>
    
</manifest>

It's working perfectly in my case.