Code Monkey home page Code Monkey logo

Comments (8)

morinel avatar morinel commented on July 21, 2024

Yes, the notification will be shown and you can process any data stored with the following code. This code fragment should be called when starting / resuming the app. You can then act on this data appropriately.

var lastData = gcm.getLastData();
if (lastData) {
    Ti.API.info("Last notification received " + JSON.stringify(lastData));
    gcm.clearLastData();
}

See the example.

from gcmpush.

giorgiopagnoni avatar giorgiopagnoni commented on July 21, 2024

Thank you. I was used to the gcm module from iamyellow where I could personalize my notification in the gcm.js file.
Can I do that here in the app? Like set the notification flags, priority, title, etc? Or do I have to set these things in my server code?

from gcmpush.

morinel avatar morinel commented on July 21, 2024

This is the stuff that you can currently configure: smallIcon, largeIcon, sound, vibrate, or set from push itself: title, message, ticker.

If there's anything else you'd like to specify, let me know.

from gcmpush.

giorgiopagnoni avatar giorgiopagnoni commented on July 21, 2024

I'm rather new to these kind of things, so sorry if I'm being dense.

If possible, I'd like to set flags like FLAG_SHOW_LIGHTS and FLAG_INSISTENT. Are they conditionally settable right now? I send all my notifications from a PHP server (code snippet below).

For example, some of my notifications need to have the FLAG_INSISTENT set, so I used to add a boolean to the message which I could then check in my Titanium code (in gcm.js) when receiving the notification (even when the app was closed).

As far as I understand this isn't possible with your code?

define( 'API_ACCESS_KEY', '***************' );
$registrationIds = array("'***************'");

$msg = array
(
    'message'       => 'message',
    'title'         => 'title title',
    'subtitle'      => 'This is a subtitle. subtitle',
    'tickerText'    => 'Ticker text here...Ticker text here...Ticker text here',
    'insistent' => 1
);

$fields = array
(
    'registration_ids'  => $registrationIds,
    'data'              => $msg
);

$headers = array
(
    'Authorization: key=' . API_ACCESS_KEY,
    'Content-Type: application/json'
);

$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, 'https://android.googleapis.com/gcm/send' );
curl_setopt( $ch,CURLOPT_POST, true );
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
$result = curl_exec($ch );
curl_close( $ch );

echo $result;

from gcmpush.

morinel avatar morinel commented on July 21, 2024

Lights are only the default:

notification.defaults |= Notification.DEFAULT_LIGHTS;

So they cannot be configured currently.

Give me some time to set the insistent flag on the notification.

from gcmpush.

giorgiopagnoni avatar giorgiopagnoni commented on July 21, 2024

Thank you. If you can make it conditional, please go ahead when and if you have some free time, but if you can't make it conditional it won't suit my purpose so don't bother. I don't need that flag on all my notifications.

from gcmpush.

morinel avatar morinel commented on July 21, 2024

Please check out new version 1.1, the setting insistent should probably be specified as a boolean, not as an int

from gcmpush.

giorgiopagnoni avatar giorgiopagnoni commented on July 21, 2024

Thank you!

from gcmpush.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.