Meteor-Community-Packages / raix-push

DEPRECATED: Push notifications for cordova (ios, android) browser (Chrome, Safari, Firefox)
https://atmospherejs.com/raix/push
MIT License
513 stars 197 forks source link

Clearing Badge Icons from Client #268

Open gkrizek opened 7 years ago

gkrizek commented 7 years ago

Is there a way to clear badge icons from the client?

For example: If someone has the app open while a notification comes in, it doesn't make a sound or show the notification, but it still adds the badge icon to app's icon. Is there a way to clear this from the client without forcing the user to exit the app and reopen it to clear it?

The only way I can see to clear the badge icon without the user's action is to send a new notification with a blank payload and a badge of 0.

carpmike commented 7 years ago

@gkrizek I have a similar problem on Android using Firebase. iOS is working fine when I use Push.setBadge(0);

Have you (or anyone else) figured out how to clear on Android?

NoMaxLand commented 7 years ago

I need a similar feature but i think it's possible to set the badge option to 0 to clear badge like on iOS.

'serverNotification'(title, text, userId, badge) {
    Push.send({
      title,
      text,
      from: 'server',
      badge: badge || 0,
      query: { userId },
    });
  },

not tested

Maybe you can set a method called when the user is on your app to clear all badges ?

gkrizek commented 7 years ago

@Makss24 I haven't touch my Meteor project in a long time, but If I remember right, I fixed the problem with this function:

 'resetBadge': function(){
    var user = Meteor.userId();
    Meteor.users.update({_id: user}, {$set: {'badge': 0}});
    Push.send({
      from: "",
      title: "",
      text: "",
      badge: 0,
      query: {
        userId: user
      }
    });

Then whenever someone did something that would warrant a badge reset, I called that function from the client. For example, I had a messaging app, so when someone clicked 'Send', that must mean that they say the unread message and the badge isn't needed anymore. (There are exceptions to that so it's not 100%)

  'click #sendbutton': function(){
    Meteor.call('resetBadge');
     ...

Source: https://github.com/gkrizek/ghostwall/

NoMaxLand commented 7 years ago

Great !

I'm beginning in push notification world and I don't use badges feature yet. But I understand that you set count badge in the database ? Raix:push doesn't manage it ?

Secondly, when you send a notification with a title and a text empty, it's not sending to user if app is closed ? edit: Apparently, the answer to my second asking is no. I just tried.

NoMaxLand commented 7 years ago

I don't know if we can use phonegap-plugin-push native functions, otherwise, clear notifications must be right with https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/API.md#pushclearallnotificationssuccesshandler-errorhandler---ios--android-only

But thanks you for your answer. It's will be easier.

rashmimhatre100 commented 6 years ago

Hello Guys, please help me out with one issue, is it possible to set badge for android using this package or I need to use some other npm. Thanks in advance.