richsage / RMSPushNotificationsBundle

NOT MAINTAINED! ⛔️ Push notifications/messages for mobile devices. Supports iOS, Android (C2DM, GCM), Blackberry and Windows Mobile (toast only). A Symfony2 bundle.
MIT License
321 stars 152 forks source link

Cannot send localized notifications #139

Open rjourde opened 8 years ago

rjourde commented 8 years ago

The setData function does not allow to send localized notifications as custom data are not inserted into the aps array. We should be able to do the following:

$payload = array(
            "alert" => array("loc-key" => $localizedData),,
        );

$message->setData($payload);

and we should get the following payload:

{
  "aps": [
    "alert": {
      "loc-key": "my message"
    }
  ]
}

instead of

{
  "aps": [ ]
  "alert": {
    "loc-key": "my message"
  }
}
grago commented 7 years ago

I got this working by using setMessage instead of setData:

$message->setMessage(['loc-key' => 'my message']);