This adds the option to send a push notification to a single specified token through the admin interface.

Useful if you've got an app that connects with a prod/stage env, you can just copy the token from there.

Comments

Xilis created an issue. See original summary.

Xilis’s picture

StatusFileSize
new6.45 KB
Xilis’s picture

Xilis’s picture

Xilis’s picture

For testing data payloads, you can use something like:

function MY_MODULE_form_push_notifications_single_push_form_alter(&$form, &$form_state, $form_id) {

  $form['message']['timestamp'] = array(
    '#type' => 'textfield',
    '#title' => t('Timestamp'),
    '#default_value' => REQUEST_TIME,
  );

}
jacob.embree’s picture

Status: Active » Needs work

I recommend adding $form['token'] to push_notifications_mass_push_form().
Either way, you should reroll the patch using git so that there aren't so many levels to the file paths. Right now -p6 is needed. git's default is -p1.
Form constructors (such as push_notifications_single_push_form()) should take $form and $form_state as parameters.

jacob.embree’s picture

Status: Needs work » Needs review
StatusFileSize
new3.55 KB
Xilis’s picture

StatusFileSize
new6.59 KB

Oops, my bad about the paths!
As for the form parameters, I copied it over from push_notifications_mass_push_form($form_state).

Using your patch, one cannot send a notification to a token which is not in the DB. Sometimes you just need to quickly check something/test out a new functionality of your mobile apps, and it's much easier to just copy the token over from a production/staging environment, than going through the whole process of connecting a phone to a local env, registering the token to a user and so on (which was the reason for the form in the first place).

Definitely agree on just adding an element to the mass_push_form through, so will work on a patch that meets halfway!

The following patch fixes the paths and adds another permission for accessing the single push page.

alesr’s picture

Ideally push notification sending should be managed from the tokens list where you should be able to select devices or users on the table (with chechboxes) and send a custom message to those devices/users only.
The addition of "external" device tokes as recipients is good. It could serve as a text field/text area on the same page but should require an additional permission.
It would be good to get an input from @haagendazs on this. It is definitely required, we just need to get on the same page with it before we deviate with patches.