Dan Pincu
Dan Pincu

Reputation: 203

Multiple push notifications using ionic push

When sending two notifications the second one always overrides the first one in the notification center. According to the docs this should happen only when using the tag:

"tag": Indicates whether each notification message results in a new entry on the notification center. If not set, each request creates a new notification. If set, and a notification with the same tag is already being shown, the new notification replaces the existing one.

However this happens to me all the time, regardless whether I set a value for the tag or not.

I even tried setting a random tag & collapse_key (which as far I understand shouldn't be related in this case, but I gave it a try). Still didn't help. Here's a sample of a notification object I'm sending:

{  
   "tokens":[  
      "my-device-token"
   ],
   "profile":"my-profile-tag",
   "notification":{  
      "message":"message",
      "android":{  
         "payload":{  
            "collapse_key":9918519,
            "tag":2825928
         }
      }
   }
}

Upvotes: 1

Views: 1242

Answers (2)

Anh Vuong Tuan
Anh Vuong Tuan

Reputation: 51

I resolved this problem. You need to add "notId" into "data" in "android". Example:

"notification": {
    "title": "testing stack notification ",
    "message":"is it working",
    "android": {               
        "data": {
            "title": "testing stack notification",
            "message": "is it working",
            "style": "inbox",
            "summaryText": "yes its %n% notifications",
            "notId": "123456"
        }
    }
}

Upvotes: 5

mike_t
mike_t

Reputation: 2691

You need to specify a unique notification id (unix timestamp for example) in the object in order not to overwrite the previous one - in your case:

{  
   "tokens":[  
      "my-device-token"
   ],
   "profile":"my-profile-tag",
   "notification":{  
      "notId": <some-unique-value-here>,
      "message":"message",
      "android":{  
         "payload":{  
            "collapse_key":9918519,
            "tag":2825928
         }
      }
   }
}

Upvotes: 0

Related Questions