Created
November 28, 2012 14:11
-
-
Save electronicbites/4161553 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PushNotifier | |
def send_notification_to_user_limited(user, message) | |
if (user.last_apn_send_date.nil? || Time.now - 12.hours > user.last_apn_send_date) | |
send_notification_to_user(user, message) | |
user.last_apn_send_date = Time.now | |
user.save | |
end | |
end | |
def send_notification_to_user(user, message) | |
if !user.device_token.nil? && | |
opts_hash = {:alert => message, environment: Rails.env, verbose: true} | |
APN.notify(user.device_token, opts_hash) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment