Comments (20)
For me the cloud:push:notification
is also not working. It's not firing.
from legacy-ionic-cloud.
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.
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.
@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.
@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.
@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.
@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.
@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.
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.
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.
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:
from legacy-ionic-cloud.
Is anyone able to provide a sample project we can try and replicate against?
from legacy-ionic-cloud.
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.
@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.
@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.
+1
from legacy-ionic-cloud.
I can confirm this issue too. $rootScope.$on('cloud:push:notification') doesn't always work.
from legacy-ionic-cloud.
@priyankmaniar you have to register push notification always the app init. It works for me.
from legacy-ionic-cloud.
@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.
@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)
- ionic v1 - facebook authentication class is invalid HOT 1
- iOS build stuck in "Building" status HOT 3
- Push notification changes HOT 1
- Ionic push notification doesnβt work when app is closed HOT 1
- build for prod fails
- Security Profile docs need updating
- "ionic io init" do not work HOT 1
- IOS - Failure while building the project environment HOT 3
- CallNumber plugin throwing error: "plugin_not_installed" after uploading build to cloud.
- Ionic V3 . No messages associated to a Notification HOT 1
- Ionic deploy - cordova.js not found after update HOT 1
- Ionic Auth - password reset through passwordResetUrl sends two mails HOT 4
- IOS *-Info.Plist. LSApplicationQueriesSchemes. HOT 1
- Setting PHOTOLIBRARY_USAGE_DESCRIPTION parameter with ionic cloud build HOT 2
- deploy.check() never resolved
- Update Docs to match Ionic Pro Dashboard
- Vulnerability due to outdated superagent dependency HOT 1
- Error: Cannot find module 'xml2js'
- Ionic Cloud - android build failed
- No migration guide
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from legacy-ionic-cloud.