Git Product home page Git Product logo

Comments (23)

aitorrod avatar aitorrod commented on May 25, 2024

Same problem here. Did you find a solution?

from ti.goosh.

bert-w avatar bert-w commented on May 25, 2024

might be related to https://jira.appcelerator.org/browse/TIMOB-24316

i know there's some titanium issues regarding intents in general. Hopefully those will be fixed in 6.0.4

from ti.goosh.

miniman42 avatar miniman42 commented on May 25, 2024

Issue is with the Modules parseBootIntent method it should be setting:
if (key.equals(INTENT_EXTRA)) { notification = intent.getExtras().getString(INTENT_EXTRA); }

from ti.goosh.

bert-w avatar bert-w commented on May 25, 2024

can you test and create a pull request for this?

from ti.goosh.

progress44 avatar progress44 commented on May 25, 2024

The issue @Bertuzb mentioned seems related. The pull request for the fix includes this commit tidev/titanium-sdk@dddb6a3
The condition above should be correct instead

if (key.equals(INTENT_EXTRA)) { notification = intent.getExtras().getString(INTENT_EXTRA); }

from ti.goosh.

bert-w avatar bert-w commented on May 25, 2024

im running 6.0.4 now though but I still cant seem to receive notification data in-app (after clicking notification) while having the app in background

from ti.goosh.

progress44 avatar progress44 commented on May 25, 2024

I'll make some tests shortly

from ti.goosh.

bert-w avatar bert-w commented on May 25, 2024

https://gist.github.com/Bertuzb/217b080b935aab362c72b213c3625368

its the testcase I used. Basically, the focus event on the main window is called when resuming from background. It should contain some data but it currently doesnt. Hope it helps

from ti.goosh.

progress44 avatar progress44 commented on May 25, 2024

[x] App closed: Notification is received and callback is fired when tapped on it
[x] App in background: Notification is received and callback is fired
[x] App in foreground: Callback is fired

Tested with SDK 6.0.0.GA and all cases still work.

from ti.goosh.

progress44 avatar progress44 commented on May 25, 2024

You should always call registerForPushNotifications because it initialises the module with the callback functions.

$.index.open();

var TiGoosh = require('ti.goosh');
TiGoosh.registerForPushNotifications({
    // The callback to invoke when a notification arrives.
    callback: function(e) {
        alert(e.data);
        /*var data = JSON.parse(e.data || '');
        Ti.API.debug("Callback", data);*/
    },

    // The callback invoked when you have the device token.
    success: function(e) {

        // Send the e.deviceToken variable to your PUSH server
        Ti.API.debug('Notifications: device token is ' + e.deviceToken);

    },

    // The callback invoked on some errors.
    error: function(err) {
        Ti.API.error('Notifications: Retrieve device token failed', err);
    }
});

from ti.goosh.

bert-w avatar bert-w commented on May 25, 2024

can you test the additional data attribute? I am also receiving the notification when the app is in background but when clicking it, the app does not receive any data.

If you could provide your testcase that would be awesome too.

I've loaded the register function of TiGoosh immediately upon startup but it does not make a change in comparison to clicking a label and firing it that way

from ti.goosh.

bert-w avatar bert-w commented on May 25, 2024

Also that first comment confused me, a fork of 6_0_X with "some new features" but last line says you tested with 6.0.0.GA

from ti.goosh.

progress44 avatar progress44 commented on May 25, 2024

I tested the module with both our fork of the sdk 6.0.4.GA and the official sdk 6.0.0.GA and it works every time. The code I'm using is the one I provided in the comment above.
alert(e.data) is correctly displayed in each case

from ti.goosh.

bert-w avatar bert-w commented on May 25, 2024

what do you do exactly with the google play services? I notice i get an error stating

[ERROR] GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.

but i am not sure how to install these and how to make it work with various android devices. Until now I was under the assumption this did not affect this issue, but perhaps it does?

from ti.goosh.

progress44 avatar progress44 commented on May 25, 2024

The message is obsolete. It's a bug in google play services but doesn't impact on the module. It works nonetheless

from ti.goosh.

bert-w avatar bert-w commented on May 25, 2024

last thing i can find is this error im getting:

05-04 13:05:38.802: E/Notification(2383): setLatestEventInfo() is deprecated and you should feel deprecated.
05-04 13:05:38.802: E/Notification(2383): java.lang.Throwable
05-04 13:05:38.802: E/Notification(2383): 	at android.app.Notification.setLatestEventInfo(Notification.java:2083)
05-04 13:05:38.802: E/Notification(2383): 	at com.android.server.am.ActivityManagerService$MainHandler.handleMessage(ActivityManagerService.java:2352)
05-04 13:05:38.802: E/Notification(2383): 	at android.os.Handler.dispatchMessage(Handler.java:102)
05-04 13:05:38.802: E/Notification(2383): 	at android.os.Looper.loop(Looper.java:154)
05-04 13:05:38.802: E/Notification(2383): 	at android.os.HandlerThread.run(HandlerThread.java:61)
05-04 13:05:38.802: E/Notification(2383): 	at com.android.server.ServiceThread.run(ServiceThread.java:46)

Im using a Samsung Galaxy S3 but its running Android 7.1 (LineageOS). I have also tried on an Android 6.0.1 device but it does not throw the above error. Both devices will not call the callback even though its registered on startup.

Can you post the tiapp manifest?

from ti.goosh.

bert-w avatar bert-w commented on May 25, 2024

hold on im experiencing some differences between the api endpoints

https://android.googleapis.com/gcm/send (old one which this module implies)
and
https://fcm.googleapis.com/fcm/send (new one which i use)

I am getting correct callback events indeed on the gcm variant

from ti.goosh.

bert-w avatar bert-w commented on May 25, 2024

well this seems to have something to do with https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages .

The payload im sending to POST https://fcm.googleapis.com/fcm/send is:

$data = json_encode(
      [
        $sendKey => $to,
        'notification' => ..., // title and body as seen in https://firebase.google.com/docs/cloud-messaging/http-server-ref#notification-payload-support
        'data' => [
          'data' => $data // some custom data
        ]
      ]
    );

Removing the notification key causes the use of data key to form a notification. The data key must then contain alert (and preferabbly also title). Defining notification takes precedence though.

The notification object behaves like (quote): "FCM automatically displays the message to end-user devices on behalf of the client app. Notification messages have a predefined set of user-visible keys and an optional data payload of custom key-value pairs."

I will try some tests with the data object, but I have to make it work for iOS devices as well (they use the same firebase service).

from ti.goosh.

progress44 avatar progress44 commented on May 25, 2024

Yeah that's true. I remember, I answered this in a previous issue. notification and data don't work well together. Check out https://github.com/caffeinalab/ti.goosh/blob/master/test-fcm to see a simple implementation

from ti.goosh.

bert-w avatar bert-w commented on May 25, 2024

ok thanks for the effort you put into this. I will try to convert my api call to use the data-setup, but i might receive conflicts on the iOS side.

It might be a good idea as well to put a notice somewhere in the readme, that points the difference out vs notification and data. The TiGoosh module states GCM/FCM support after all but it has some gotcha's

from ti.goosh.

progress44 avatar progress44 commented on May 25, 2024

Yeah true. We'll update the documentation. Thanks for the feedback

from ti.goosh.

zulfiandri avatar zulfiandri commented on May 25, 2024

hallo , I have problem

I use SDK: 6.0.4 , Appcelerator Studio build: 4.8.1
ti.goosh: 2.0.6
device: Lenovo k4 note a7010
[x] App closed: Notification is received and callback is fired when tapped on it
[x] App in foreground: Callback is fired

My problem is :
[x] App in background: Notification is received and callback not fired

from ti.goosh.

Lenndev avatar Lenndev commented on May 25, 2024

@zulfiandri still encountering this problem?

from ti.goosh.

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.