Possible to pass parameters when starting a watch app?

55 Views Asked by At

I have been trying to develop a watch app and I am facing some problems with AppMessage. When I start an app on the watch and send message immediately, the message fails to deliver. I expect this is because the app needs to initialize and register handlers for app message and every thing else before being able to receive message. I was just wondering if it was possible to pass a string to app at startup? Also is it possible to check if a certain app is already running on the watch i.e being displayed?

Thanks for the help.

1

There are 1 best solutions below

2
On

When I start an app on the watch and send message immediately, the message fails to deliver.

Assuming you mean sending an AppMessage from the JS component to C, you should be doing that in your ready event. (Documentation for Initializing your JavaScript App)

Also make sure to register handlers before appmessage_open() in C.

I was just wondering if it was possible to pass a string to app at startup?

No. What would pass the string and how would it know what to pass? If it's constant, then why does it need to be passed? If not, again, what decides what to pass?

Also is it possible to check if a certain app is already running on the watch i.e being displayed?

Well, your code would only execute when your app is running. And since only one app can run at a time, that state would always be true when the certain app is your app and false otherwise.