ProMotion-push 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ProMotion/delegate_notifications.rb +40 -1
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92d47c1b7c5832101f3e86a8d4bdf1c5a411859a
|
4
|
+
data.tar.gz: 0cd531d2a261031e3bbcc2fac090ea6f296ef9e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26db989c1ab260ccc514557996d32088ef6a9bfd11e5cd54f99a1300a60c2638ce11627b88220a698144a3812630f513e87cc89ba93676b082c2810fbbe77d55
|
7
|
+
data.tar.gz: 41e2d24ba08d7a8cef9406dd10012ab91c2dac2160079a3422bb086cd2b4a44d05ef7696801d568618ba43d97a380ed683666c5ea43a630e627a132b46ec2957
|
@@ -10,6 +10,19 @@ module ProMotion
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
+
def register_push_notification_category(category_name, actions, options = {})
|
14
|
+
return unless actionable_notifications?
|
15
|
+
|
16
|
+
@push_notification_categories ||= []
|
17
|
+
UIMutableUserNotificationCategory.new.tap do |category|
|
18
|
+
minimal = options[:minimal]
|
19
|
+
category.setActions(minimal, forContext: UIUserNotificationActionContextMinimal) if minimal
|
20
|
+
category.setActions(actions, forContext: UIUserNotificationActionContextDefault)
|
21
|
+
category.identifier = category_name
|
22
|
+
@push_notification_categories << category
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
13
26
|
def register_for_push_notifications(*notification_types)
|
14
27
|
notification_types = Array.new(notification_types)
|
15
28
|
notification_types = [ :badge, :sound, :alert, :newsstand ] if notification_types.include?(:all)
|
@@ -17,7 +30,23 @@ module ProMotion
|
|
17
30
|
types = UIRemoteNotificationTypeNone
|
18
31
|
notification_types.each { |t| types = types | map_notification_symbol(t) }
|
19
32
|
|
20
|
-
|
33
|
+
register_for_push_notification_types(types)
|
34
|
+
end
|
35
|
+
|
36
|
+
def register_for_push_notification_types(types)
|
37
|
+
UIApplication.sharedApplication.tap do |application|
|
38
|
+
if actionable_notifications?
|
39
|
+
settings = UIUserNotificationSettings.settingsForTypes(types, categories: @push_notification_categories)
|
40
|
+
application.registerUserNotificationSettings settings
|
41
|
+
application.registerForRemoteNotifications
|
42
|
+
else
|
43
|
+
application.registerForRemoteNotificationTypes types
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def actionable_notifications?
|
49
|
+
UIApplication.sharedApplication.respond_to?(:registerUserNotificationSettings)
|
21
50
|
end
|
22
51
|
|
23
52
|
def unregister_for_push_notifications
|
@@ -36,6 +65,11 @@ module ProMotion
|
|
36
65
|
types
|
37
66
|
end
|
38
67
|
|
68
|
+
def received_push_notification_with_action(notification, action)
|
69
|
+
@aps_notification = ProMotion::PushNotification.new(notification)
|
70
|
+
on_push_notification_action(action, @aps_notification) if respond_to?(:on_push_notification_action)
|
71
|
+
end
|
72
|
+
|
39
73
|
def received_push_notification(notification, was_launched)
|
40
74
|
@aps_notification = ProMotion::PushNotification.new(notification)
|
41
75
|
on_push_notification(@aps_notification, was_launched) if respond_to?(:on_push_notification)
|
@@ -55,6 +89,11 @@ module ProMotion
|
|
55
89
|
received_push_notification(notification, application.applicationState != UIApplicationStateActive)
|
56
90
|
end
|
57
91
|
|
92
|
+
def application(application, handleActionWithIdentifier: action_identifier, forRemoteNotification: notification, completionHandler: callback)
|
93
|
+
received_push_notification_with_action(notification, action_identifier)
|
94
|
+
callback.call
|
95
|
+
end
|
96
|
+
|
58
97
|
protected
|
59
98
|
|
60
99
|
def map_notification_symbol(symbol)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ProMotion-push
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamon Holmgren
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ProMotion
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0
|
47
|
+
version: '1.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0
|
54
|
+
version: '1.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,9 +97,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
97
|
version: '0'
|
98
98
|
requirements: []
|
99
99
|
rubyforge_project:
|
100
|
-
rubygems_version: 2.
|
100
|
+
rubygems_version: 2.4.5
|
101
101
|
signing_key:
|
102
102
|
specification_version: 4
|
103
103
|
summary: Adds push notification support to ProMotion. Extracted from ProMotion.
|
104
104
|
test_files: []
|
105
|
-
has_rdoc:
|