Module: ProMotion::DelegateNotifications
- Included in:
- Delegate
- Defined in:
- lib/ProMotion/delegate/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) ⇒ 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.
4 5 6 |
# File 'lib/ProMotion/delegate/delegate_notifications.rb', line 4 def aps_notification @aps_notification end |
Instance Method Details
#application(application, didReceiveRemoteNotification: notification) ⇒ Object
CocoaTouch
48 49 50 |
# File 'lib/ProMotion/delegate/delegate_notifications.rb', line 48 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
6 7 8 9 10 |
# File 'lib/ProMotion/delegate/delegate_notifications.rb', line 6 def check_for_push_notification() if && [UIApplicationLaunchOptionsRemoteNotificationKey] received_push_notification [UIApplicationLaunchOptionsRemoteNotificationKey] end end |
#received_push_notification(notification) ⇒ Object
41 42 43 44 |
# File 'lib/ProMotion/delegate/delegate_notifications.rb', line 41 def received_push_notification(notification) @aps_notification = PM::PushNotification.new(notification) on_push_notification(@aps_notification) if respond_to?(:on_push_notification) end |
#register_for_push_notifications(*notification_types) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ProMotion/delegate/delegate_notifications.rb', line 12 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 types = types | UIRemoteNotificationTypeBadge if notification_types.include?(:badge) types = types | UIRemoteNotificationTypeSound if notification_types.include?(:sound) types = types | UIRemoteNotificationTypeAlert if notification_types.include?(:alert) types = types | UIRemoteNotificationTypeNewsstandContentAvailability if notification_types.include?(:newsstand) UIApplication.sharedApplication.registerForRemoteNotificationTypes types end |
#registered_push_notifications ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ProMotion/delegate/delegate_notifications.rb', line 29 def registered_push_notifications mask = UIApplication.sharedApplication.enabledRemoteNotificationTypes types = [] types << :badge if mask & UIRemoteNotificationTypeBadge types << :sound if mask & UIRemoteNotificationTypeSound types << :alert if mask & UIRemoteNotificationTypeAlert types << :newsstand if mask & UIRemoteNotificationTypeNewsstandContentAvailability types end |
#unregister_for_push_notifications ⇒ Object
25 26 27 |
# File 'lib/ProMotion/delegate/delegate_notifications.rb', line 25 def unregister_for_push_notifications UIApplication.sharedApplication.unregisterForRemoteNotifications end |