Pebble Intents

Post your questions and help other users.

Moderator: Martin

Post Reply
mathieson
Posts: 51
Joined: 13 Aug 2013 18:16

Pebble Intents

Post by mathieson » 13 Aug 2013 18:23

Hello,

I was hoping for some help with this.

I am trying to send a notification to my Pebble, I believe I can do this with Intents, and I found this online:
http://s476905316.websitehome.co.uk/blog/?p=612

Apparently it is possible from Llama, however I am not certain for the correct format for Automagic.

I am using the action "Broadcast Intent" with com.getpebble.action.SEND_NOTIFICATION as action, I also add the following extras:
putString("messageType", "PEBBLE_ALERT");
putString("sender", "Automagic");
putString("notificationData", "[{\"title\":\"Test Notification\",\"body\":\"This is a test event\"}]");

I believe this should work but it does not, am I correct?

Here is the info from Pebble:
http://developer.getpebble.com/1/03_API ... 3_Android/

Thanks,
Sam.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Pebble Intents

Post by Martin » 14 Aug 2013 17:19

Hello Sam

Unfortunately I don't have a pebble to test it but it could be caused by the variable replacement support in strings in the last putString statement:
putString("notificationData", "[{\"title\":\"Test Notification\",\"body\":\"This is a test event\"}]");

Automagic will try to evaluate the text between the curly brackets as an expression.

You can use single quotes and remove the double quote escape to see if this fixes the problem:
putString("notificationData", '[{"title":"Test Notification","body":"This is a test event"}]');

Regards
Martin

mathieson
Posts: 51
Joined: 13 Aug 2013 18:16

Re: Pebble Intents

Post by mathieson » 15 Aug 2013 03:01

Martin,

Thanks!

That did the trick! :)

ZSasha
Posts: 103
Joined: 11 Oct 2013 03:48

Re: Pebble Intents

Post by ZSasha » 08 Dec 2013 22:10

Martin wrote: You can use single quotes and remove the double quote escape to see if this fixes the problem:
putString("notificationData", '[{"title":"Test Notification","body":"This is a test event"}]');

Regards
Martin
Hi Martin,

I am trying to do the same and it works but now I am not too sure how to pass a variable to this expression.
Could you please give us an example?


Also if it is not too much trouble - would it be possible to create a special action for Pebble in your next release? It is quite difficult and time consuming to fill in all this fields.
Many thanks.

P.S. I know about PebbleNotifier but it behaves strangely - it may stop working for unknown reason and then start working again.
However sending a broadcast seems to be working all the time - this is why I want to be able to send a broadcast my myself rather then relying on PN.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Pebble Intents

Post by Martin » 09 Dec 2013 17:18

Hi,

You can concatenate multiple strings using the + operator and add the variable in the middle:

Code: Select all

title = "Testtitle";
body = "Testbody";
data = '[{"title":"' + title + '","body":"' + body + '"}]';
putString("notificationData", data);
I can add an entry to my todo-list to add a special pebble action but I can not promise anything yet and it will certainly take quite some time since the list is growing faster than I can actually implement the features.

Regards,
Martin

Post Reply