Module: ProMotion::DelegateNotifications
- Defined in:
- lib/ProMotion/delegate_notifications.rb
Instance Attribute Summary collapse
-
#aps_notification ⇒ Object
Returns the value of attribute aps_notification.
Instance Method Summary collapse
-
#application(application, didReceiveRemoteNotification: notification) ⇒ Object
CocoaTouch.
- #check_for_push_notification(options) ⇒ Object
- #received_push_notification(notification, was_launched) ⇒ Object
- #register_for_push_notifications(*notification_types) ⇒ Object
- #registered_push_notifications ⇒ Object
- #unregister_for_push_notifications ⇒ Object
Instance Attribute Details
#aps_notification ⇒ Object
Returns the value of attribute aps_notification.
5 6 7 |
# File 'lib/ProMotion/delegate_notifications.rb', line 5 def aps_notification @aps_notification end |
Instance Method Details
#application(application, didReceiveRemoteNotification: notification) ⇒ Object
CocoaTouch
46 47 48 |
# File 'lib/ProMotion/delegate_notifications.rb', line 46 def application(application, didRegisterForRemoteNotificationsWithDeviceToken:device_token) on_push_registration(device_token, nil) if respond_to?(:on_push_registration) end |
#check_for_push_notification(options) ⇒ Object
7 8 9 10 11 |
# File 'lib/ProMotion/delegate_notifications.rb', line 7 def check_for_push_notification() if && [UIApplicationLaunchOptionsRemoteNotificationKey] received_push_notification [UIApplicationLaunchOptionsRemoteNotificationKey], true end end |
#received_push_notification(notification, was_launched) ⇒ Object
39 40 41 42 |
# File 'lib/ProMotion/delegate_notifications.rb', line 39 def received_push_notification(notification, was_launched) @aps_notification = ProMotion::PushNotification.new(notification) on_push_notification(@aps_notification, was_launched) if respond_to?(:on_push_notification) end |
#register_for_push_notifications(*notification_types) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/ProMotion/delegate_notifications.rb', line 13 def register_for_push_notifications(*notification_types) notification_types = Array.new(notification_types) notification_types = [ :badge, :sound, :alert, :newsstand ] if notification_types.include?(:all) types = UIRemoteNotificationTypeNone notification_types.each { |t| types = types | map_notification_symbol(t) } UIApplication.sharedApplication.registerForRemoteNotificationTypes types end |
#registered_push_notifications ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ProMotion/delegate_notifications.rb', line 27 def registered_push_notifications mask = UIApplication.sharedApplication.enabledRemoteNotificationTypes types = [] types << :badge if mask & UIRemoteNotificationTypeBadge > 0 types << :sound if mask & UIRemoteNotificationTypeSound > 0 types << :alert if mask & UIRemoteNotificationTypeAlert > 0 types << :newsstand if mask & UIRemoteNotificationTypeNewsstandContentAvailability > 0 types end |
#unregister_for_push_notifications ⇒ Object
23 24 25 |
# File 'lib/ProMotion/delegate_notifications.rb', line 23 def unregister_for_push_notifications UIApplication.sharedApplication.unregisterForRemoteNotifications end |