Hi,

I'm using PhoneGap through AppPresser to create my app for android and apple. I'm wondering is it possible for me to send out notifications from within the app instead of logging in through the pushwoosh back end or wordpress backend? I want to enable contributors on my app to have the ability to send out notifications.

Thanks!

asked 17 May '16, 00:11
Bryan's gravatar image

Bryan
112

Bryan,

Did you try the following:

var notification = {

                send_date: "now",
                ignore_user_timezone: true,
                content: $('textarea#msg').val() // or $('#msg').val(), depends on how you want to obtain the content
            }

$.ajax({
    type: "POST",
    url: "https://cp.pushwoosh.com/json/1.3/createMessage",
    data: JSON.stringify({
        "request": {
            "application": "APPLICATION CODE",
            "auth": "API TOKEN",
            "notifications": notification

        }
    }),
    dataType: "json"
}).done(function(data) {
    console.log(data);
});
permanent link
answered 18 May '16, 11:41
Vitaly%20Romanychev's gravatar image

Vitaly Roman...
2213

Hello,

Please note that for now sending notifications from within the app is available with our Native Android SDK only. Our PhoneGap plugin does not support this functionality.

Please take a look at the Javascript snippet below - it can be useful in case of using Cordova:

$.ajax({
    type: "POST",
    url: "https://cp.pushwoosh.com/json/1.3/createMessage",
    data: JSON.stringify({
        "request": {
            "application": "APPLICATION CODE",
            "auth": "API TOKEN",
            "notifications": [{
                "send_date": "now",
                "ignore_user_timezone": true,
                "content": "Hello world!"
            }]
        }
    }),
    dataType: "json"
}).done(function(data) {
    console.log(data);
});
permanent link
answered 17 May '16, 11:10
Max%20Kuzakov's gravatar image

Max Kuzakov
4165

I see.. Is the Javascript snippet you provide a dynamic message or is it a static one? I'm guessing this particular snippet will send out a "Hello world!" push notification correct?

What I mean my dynamic is, say the app asks the user what message they want to send out from within the app then it will send it out with whatever message was typed into some sort of input box.

(17 May '16, 18:47) Bryan Bryan's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×446
×165
×111
×8

question asked: 17 May '16, 00:11

question was seen: 821 times

last updated: 18 May '16, 11:41