Skip to content

Instantly share code, notes, and snippets.

@adiwids
Created October 5, 2018 11:46
Show Gist options
  • Save adiwids/c63845f9c650903a0c27c7368b8de9cd to your computer and use it in GitHub Desktop.
Save adiwids/c63845f9c650903a0c27c7368b8de9cd to your computer and use it in GitHub Desktop.
# Find user that has registered device (reg token registered) on server
user = User.find_by(email: '<email>')
# Find last notification object received by that user
notif = PushNotification.where(recipient_id: u.id).last
# Assign notificatable object (might be object of Post, Comment, etc) from 'notif'
obj = notif.notificatable
# Destroy last notification log, assigned as 'notif' since server won't send any duplicate notification object
notif.destroy
# Re-send notification
PushNotification.broadcast_notifications_for(obj, [user])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment