Coder Social home page Coder Social logo

Comments (20)

koenoe avatar koenoe commented on May 28, 2024

For me the cloud:push:notification is also not working. It's not firing.

from legacy-ionic-cloud.

ericb avatar ericb commented on May 28, 2024

Are you correctly using $scope for the context of your app / code placement? You mentioned it works when the app is in the background/closed, but does that just mean that the notification is displayed in the notification area? If you click the notification when the app is closed, does the cloud:push:notification event fire then?

from legacy-ionic-cloud.

koenoe avatar koenoe commented on May 28, 2024

I'm receiving the actual push notification. I've put some logging in my ionic-cloud-bundle file now and I discovered there's also an event cloud:push:register. If I listen to this one for example I successfully receive it. It doesn't matter whether I close the app and click the notification or I leave the app open. In both cases I'm not receiving the cloud:push:notification event. I'm using Ionic 1.3.1 and Ionic Cloud 0.10.0.

I initialise Ionic Cloud as suggested in my app config block. I listen to the events in my app run block:

$rootScope.$on('cloud:push:register', onDeviceTokenRegistered); // works
$rootScope.$on('cloud:push:notification', onPushNotification); // doesn't work

from legacy-ionic-cloud.

ericb avatar ericb commented on May 28, 2024

@koenoe Both events fire in the same way, and are registered internally at the same time. What happens if you try and listen for events directly from the Push Plugin? I haven't run this code directly, but it should be something like:

$ionicPush.plugin.on('notification', function(data) { console.log(data); });

You can see the relevant callback registration in the cloud client codebase if it helps.

Also, are you using the latest version of both the cloud client and push plugin?

from legacy-ionic-cloud.

koenoe avatar koenoe commented on May 28, 2024

@ericb Thanks for the suggestion. I've tried it, but no luck.
I'm using ionic-cloud 0.10.0 and the phonegap-plugin-push 1.8.2

from legacy-ionic-cloud.

ericb avatar ericb commented on May 28, 2024

@koenoe Is an error thrown, or does it just not do anything? If you do the same thing but use 'registration' as the event type, does it then log something? If so, this would point at something going wrong on the plugin side (perhaps an older version or misconfiguration, etc)

from legacy-ionic-cloud.

koenoe avatar koenoe commented on May 28, 2024

@ericb I literally have no idea what went wrong. But after I started this morning again and had to reboot my MacBook and reopened Xcode, it all of a sudden works. Didn't change anything in the code! I see the 'payload' is in a property 'additionalData', so I'm going to change that now. Thanks, but I think this issue can be closed. Unless @RonSB still have problems?

from legacy-ionic-cloud.

ericb avatar ericb commented on May 28, 2024

@koenoe Odd. Maybe something wasn't properly picking up the latest versions of the plugin or cloud client? Either way, glad to hear it's fixed up for you.

Cheers 🍻

from legacy-ionic-cloud.

RonSB avatar RonSB commented on May 28, 2024

Hi @ericb

Sorry for delay...

I'm using the last version for ionic/cloud (0.10.0) and the problem persisted in android, I will test in IOS.

Regards.

from legacy-ionic-cloud.

RonSB avatar RonSB commented on May 28, 2024

Hi @ericb

I'm using the last ionic/[email protected]
I wrote this code in App.js file and I tested:

 $rootScope.$on('cloud:push:notification', function (event, data) {
        alert('app $rootScope -- cloud:push:notification ' + JSON.stringify(data));
  });

and now it fired but only when the app is closed/background.
I don't know if I have to write this code in other place?

from legacy-ionic-cloud.

Lestt avatar Lestt commented on May 28, 2024

Hi all,

I'am using the lastest ionic/[email protected], phonegap-plugin-push@~1.8.4 (because i am using [email protected]), [email protected].

I can receive notification on Android (app in foreground or background), but still the same probleme as here, the cloud:push:notification event is not fired at all.
I put this code in my app.js, inside the $ionicPlatform.ready function (which is inside the run function):

.run(function($ionicPlatform, $rootScope) {
    $ionicPlatform.ready(function() {
        $rootScope.$on('cloud:push:notification', function(event, data) {
            alert('app $rootScope -- cloud:push:notification ' + JSON.stringify(data));
        });
    });
});

Did i miss something ? Thanks for the help !

@ericb : I've tried $ionicPush.plugin.on('notification', function(data) { console.log(data); }); by injecting $ionicPush service but i got this error: Uncaught TypeError: Cannot read property 'on' of undefined. I can't find a way to susbcribe to the event directly with ionicPush service.

When i active debug mode via $ionicCloudProvider, i got this line printed in the console when i click on the notification: Ionic Push (debug): notification received: <PushMessage ["Test"]>, but still no event fired in my app.

When i log the $ionicCloud service, i can find that:

image

from legacy-ionic-cloud.

ericb avatar ericb commented on May 28, 2024

Is anyone able to provide a sample project we can try and replicate against?

from legacy-ionic-cloud.

Lestt avatar Lestt commented on May 28, 2024

First, thank you @ericb for your work.
I found why I didn't get the event. The thing is i am testing my app with livereload. I initialized the push plugin only when the user log in. So in my case, when i use livereload, all the data stored in localStorage (concerning my app or push notifications) are present, but i don't call the code to initialize it between 2 livereload sessions. Then no event is fired.
I re-tested and each time i saved my code and livereload reloaded the app, i logged out and logged into my app, and the event is fired as expected.
I don't know if this should be mentioned somewhere in the doc, and if this behavior seems normal for you.

Thanks for your time ... and Merry Christmas and happy new year!

from legacy-ionic-cloud.

ericb avatar ericb commented on May 28, 2024

@Lestt Thanks for the warm wishes, and thank you very much for the update with the livereload information. This is something I wasn't aware of and I definitely think we should make a note about given that more than a few people have run into this issue.

Thanks again! Cheers 🍻

from legacy-ionic-cloud.

gagansaini2 avatar gagansaini2 commented on May 28, 2024

@Lestt @ericb
In my App, device is registered with ionicPush when a user log in into the app, so when a notification came $rootScope.$on('cloud:push:notification') triggers as expected,but when i close the app and restart it again $rootScope.$on('cloud:push:notification') function stops triggering(but i receives the pushes in my notification shade).
So, to trigger push i have to log out and log in to the app again without closing it.

Plz help me with this,,i am struggling with this for weeks

from legacy-ionic-cloud.

zmaximo1990 avatar zmaximo1990 commented on May 28, 2024

+1

from legacy-ionic-cloud.

priyankmaniar avatar priyankmaniar commented on May 28, 2024

I can confirm this issue too. $rootScope.$on('cloud:push:notification') doesn't always work.

from legacy-ionic-cloud.

zmaximo1990 avatar zmaximo1990 commented on May 28, 2024

@priyankmaniar you have to register push notification always the app init. It works for me.

from legacy-ionic-cloud.

priyankmaniar avatar priyankmaniar commented on May 28, 2024

@zmaximo1990 Thanks so much for responding. Do you mean $ionicCloudProvider.init? I have it in app.js in the .config block.

Here's how it looks.

`.config(function ($ionicCloudProvider) {

    $ionicCloudProvider.init({
        "core": {
            "app_id": "XXX"
        },
        "push": {
            "sender_id": "XXX",
            "pluginConfig": {
                "ios": {
                    "badge": true,
                    "sound": true
                },
                "android": {
                    "iconColor": "XXX",
                    "icon": "icon"
                }
            }
        }
    });

})`

from legacy-ionic-cloud.

zmaximo1990 avatar zmaximo1990 commented on May 28, 2024

@priyankmaniar I mean that you have to bind 'cloud:push:notification' event always that app run. In my run bock bind this event on $rootScope if user has logged in.

I hope it help you.

from legacy-ionic-cloud.

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.