Languages

Menu
Sites
Language
Simple notification which pushes user to my app

Hi everyone!

I'm developing an IM app and I want to make a notification which will(on click) bring user back to my app and show suitable view to him.

This is my code (in CoffeeScript)

appControl = new tizen.ApplicationControl(
        "http://tizen.org/appcontrol/operation/view_chat",
        null)
 
notificationDict = {
        content : message.get('text')
        iconPath : 'icon.png'
        vibration : true
        appControl : appControl
}
notification = new tizen.StatusNotification(
        "SIMPLE", 
        "#{contact.get('nick')}: #{message.get('text')}", 
        notificationDict
)
tizen.notification.post(notification)

 

How can I do that? Am I on the right way? Notification docs are not very useful...

Edited by: Brock Boland on 17 Mar, 2014 Reason: Paragraph tags added automatically from tizen_format_fix module.

Responses

20 Replies
Lakshmi Grandhi
Your chat application have to be registered in the config.xml file for this functionality to work follow this link for help : https://developer.tizen.org/help/topic/org.tizen.web.appprogramming/html/guide/app_guide/application_service.htm?resultof=%22%61%70%70%63%6f%6e%74%72%6f%6c%22%20 add the above schema to your config.xml file
Lakshmi Grandhi
Your chat application have to be registered in the config.xml file for this functionality to work follow this link for help : https://developer.tizen.org/help/topic/org.tizen.web.appprogramming/html... <tizen:app-control> <src name="[PAGE]"/> <operation name="[OPERATION]"/> <uri name="[URI_SCHEME]"/> <mime name="[MIME_TYPE]"/> </tizen:app-control> add the above schema to your config.xml file
Dmitry Utkin
Yes, I've done that of course. The thing is that after click on this notification my app is being started from the ground up, it's relaunched and I want to just pass some kind of a callback func which will be fired up when notification is clicked.
Lakshmi Grandhi
Create another .html file in your application where you want to go after clicking the notification . And give that file name <src name="[PAGE]"/> here in config.xml .
Dmitry Utkin
Can't see how that helps. I've created a single-page JQM app which maintains it's state with BackboneJS and loading some other .html page does nothing useful in my case. Maybe I'm missing something in the docs and there's some other way for different .html pages to interact and share state of the window object, but I'm can't see it...
Lakshmi Grandhi
the other html file will have the content you want to view when clicking on the notification , and you can have that html file controlled by the JS file you have
Dmitry Utkin
Where can I find an example of a case like this?
Lakshmi Grandhi
I've created two web apps ( AppOne & AppTwo ) . AppOne Creates a notification , when clicked on notification Apptwo's index1.html page will be called AppOne main.js :
appControl = new tizen.ApplicationControl(
			"http://tizen.org/appcontrol/operation/view_chat",
			null);

	notificationDict = {
			content : "testing",
			iconPath : 'icon.png',
			vibration : true,
			appControl : appControl,
	};
	 var notification = new tizen.StatusNotification("SIMPLE",
             "Simple notification", notificationDict);
	tizen.notification.post(notification);
In AppTwo create html file other than index.html say index1.html (This will have the content you want to view when clicked on notification) . So add the below code in config file of AppTwo
<tizen:app-control>
		<tizen:src name="index1.html" />
		<tizen:operation name="http://tizen.org/appcontrol/operation/view_chat" />
	</tizen:app-control>
Write sample for this and see
Dmitry Utkin
This case is totally clear for me. Let me explain one more time what I've got: 1) Single-page app, it has only ONE html file with multiple JQM-pages with all navigation controlled via BackboneJS and $.mobile.changePage() 2) SIMPLE notification that my app is registered to catch on that ONE html page Behavior that I want to see is almost the same as clicking on an icon of already running app on main screen. It just opens there where it was left by user. The only exception is I want to show the chat page when my notification is clicked, that's all. I don't want to relaunch it, don't want to show or load any other html page. I've been exploring samples and I found a BluetoothChat that's very similar. Only one page, all app logic is in JS... BUT it doesn't use notification api :( I guess for the very same reason that I can't do this.
Dmitry Utkin
Hi again, Lakshmi! Any ideas how I can accomplish "click-to-resume" in my case? I still hope for your help. Or maybe I can ask developers of this part of the platform directly?
Lakshmi Grandhi
Hi, Using appcontrol logic, in case of native app its resuming the state of application where as in case of web application its relaunching the page. This is bug in sdk. I will raise bug.
Dmitry Utkin
Thanks a lot for your help!
Dmitry Utkin
Anything new on timeframe for this bugfix?
Alexander AVSukhov
Hi gothy, You can try the following: Register app-control in your app: Create notification: var appControlData = new tizen.ApplicationControlData("data", [data]); var appControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/my", null, "*/*", null ,[appControlData]) var notificationDict = { content: "notification",/ vibration: true, appControl: appControl }; var notification = new tizen.StatusNotification("SIMPLE", "Simple notification", notificationDict); tizen.notification.post(notification); And after click notification, on your page to receive data: var reqAppControl = tizen.application.getCurrentApplication().getRequestedAppControl(); console.log(reqAppControl.appControl.data[0]);
Dmitry Utkin
Hi Alexander! The main problem is still there, when I click the notification, the page that's shown is loading from the very beginning. And I want to preserve the whole app context with all it's state. Is that even possible?
Alexander AVSukhov
If I understand correctly, you need resume app instead to create app?
Dmitry Utkin
Yes! On new incoming message I post a notification so user could just click it and go to the chat view.
Alexander AVSukhov
At the moment I have not found a solution to your problem. It may be worth creating a separate screen to display a message conversation, which will be opened by clicking on the notification.
Dmitry Utkin
Thanks anyway!
Dmitry Utkin
Anything new on this issue in 2.2 maybe? Is there a bug report in bug tracker? Couldn't find in on bugs.tizen.org