motion-takeoff 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +56 -4
- data/lib/motion-takeoff.rb +0 -3
- data/lib/project/reminders.rb +60 -0
- data/lib/project/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 892428cb8adf421a5e32d48ec69fc0fe9e577388
|
4
|
+
data.tar.gz: 350b88873a1d02a82c04d2c725d9e52782dfdc52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0abd181eafbc8aff7ae8420eca855434e66682fce004f886843cbb677fad6070ace6c6e4da9cc84b3adc6e9f16f4b94a4d4be501f5a4301813688111222e1b20
|
7
|
+
data.tar.gz: 1a281344fe8d4b767810d13b2968435c13be18a9ce742aee2816a0caff32a70c3c47f89110c922eb69f90d1711c1fbb4c3bf2a59897f8eb1e857ed25057d00bb
|
data/README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# motion-takeoff
|
2
2
|
|
3
|
-
A RubyMotion specific iOS gem that helps you do things at launch.
|
3
|
+
A RubyMotion specific iOS gem that helps you do things at launch. Currently, there is two one modules in this gem: `Messages` & `Reminders.
|
4
4
|
|
5
|
-
|
5
|
+
The `Messages` module will allow you to schedule alerts to users at certain launch counts.
|
6
6
|
|
7
|
-
|
7
|
+
The `Reminders` module is a nice wrapper for `UILocalNotification` to help you set reminders for the user to come back to your app at specified periods of time. It supports all the options of `UILocalNotification` and does some fancy interpretation of dates for you if needed.
|
8
|
+
|
9
|
+
More modules are planned for the future. This gem is in its infancy. Please help me make it better!
|
8
10
|
|
9
11
|
## Installation
|
10
12
|
|
@@ -29,9 +31,59 @@ end
|
|
29
31
|
```
|
30
32
|
This will display an alert to the user on the 1st, 3rd, and 500th launches of the app.
|
31
33
|
|
34
|
+
## Usage: Reminder Module
|
35
|
+
|
36
|
+
The reminders module is a nice wrapper on `UILocalNotification` and makes it easy to schedule reminders to come back and use your app!
|
37
|
+
|
38
|
+
You should always reset all local notifications when your app becomes active:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
def applicationDidBecomeActive(application)
|
42
|
+
MotionTakeoff::Reminders.reset
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
And here's how to set multiple reminders when your app enters the background:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
def applicationDidEnterBackground(application)
|
50
|
+
MotionTakeoff::Reminders.schedule(
|
51
|
+
body: "Fires 20 seconds after the user closes your app.",
|
52
|
+
fire_date: 20 #seconds
|
53
|
+
)
|
54
|
+
|
55
|
+
MotionTakeoff::Reminders.schedule(
|
56
|
+
body: "Fires 10 seconds later.",
|
57
|
+
fire_date: Time.now + 30 #Time object in the future
|
58
|
+
)
|
59
|
+
end
|
60
|
+
```
|
61
|
+
|
62
|
+
The `MotionTakeoff::Reminders.schedule` method takes a hash of options that are send to the `UILocalNotification`. `body` and `fire_date` are required and will raise an exception if you try to schedule a notification without those teo options. Here's all the default options:
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
{
|
66
|
+
action: nil,
|
67
|
+
launch_image: nil,
|
68
|
+
badge_number: 0,
|
69
|
+
has_action: true,
|
70
|
+
repeat: {
|
71
|
+
calendar: nil,
|
72
|
+
interval: 0
|
73
|
+
},
|
74
|
+
time_zone: NSTimeZone.defaultTimeZone,
|
75
|
+
sound: UILocalNotificationDefaultSoundName,
|
76
|
+
user_info: {}
|
77
|
+
}
|
78
|
+
```
|
79
|
+
|
80
|
+
You can read about what each of these does in [Apple's UILocalNotification Documentation](https://developer.apple.com/library/IOs/documentation/iPhone/Reference/UILocalNotification_Class/Reference/Reference.html), but I've tried to pick sane defaults.
|
81
|
+
|
82
|
+
If you pass a `NSCalendarUnit` for the `repeat` option, we'll automatically assume you want to use `NSCalendar.currentCalendar` as the repeat calendar. Possible values of `repeat` are as found in the [`NSCalendarUnit` documentation](https://developer.apple.com/library/IOs/documentation/Cocoa/Reference/Cocoa/Reference/Foundation/Classes/NSCalendar_Class/Reference/NSCalendar.html#//apple_ref/doc/c_ref/NSCalendarUnit).
|
83
|
+
|
32
84
|
## Future plans
|
33
85
|
|
34
|
-
I'd like it to be able to be a multi-purpose tool for doing things at launch other than just alerting users. Things like asking for ratings in the iTunes store and scheduling other activities likes clearing caches on the 10th load or checking a server every load, etc.
|
86
|
+
I'd like it to be able to be a multi-purpose tool for doing things at launch other than just alerting users. Things like asking for ratings in the iTunes store and scheduling other activities likes clearing caches on the 10th load or checking a server every other load, etc.
|
35
87
|
|
36
88
|
## Contributing
|
37
89
|
|
data/lib/motion-takeoff.rb
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
module MotionTakeoff
|
2
|
+
class Reminders
|
3
|
+
|
4
|
+
def self.schedule (opts)
|
5
|
+
raise "You must specify a :body" unless opts[:body]
|
6
|
+
raise "You must specify a :fire_date" unless opts[:fire_date]
|
7
|
+
|
8
|
+
opts = {
|
9
|
+
action: nil,
|
10
|
+
launch_image: nil,
|
11
|
+
badge_number: 0,
|
12
|
+
has_action: true,
|
13
|
+
repeat: {
|
14
|
+
calendar: nil,
|
15
|
+
interval: 0
|
16
|
+
},
|
17
|
+
time_zone: NSTimeZone.defaultTimeZone,
|
18
|
+
sound: UILocalNotificationDefaultSoundName,
|
19
|
+
user_info: {}
|
20
|
+
|
21
|
+
}.merge(opts)
|
22
|
+
|
23
|
+
# Fix the repeat if they just send the interval.
|
24
|
+
unless opts[:repeat].is_a? Hash
|
25
|
+
opts[:repeat] = {
|
26
|
+
calendar: NSCalendar.currentCalendar,
|
27
|
+
interval: opts[:repeat]
|
28
|
+
}
|
29
|
+
end
|
30
|
+
# Interpret the fire date to an NSDate class it they specified a number of seconds
|
31
|
+
if opts[:fire_date].is_a? Fixnum
|
32
|
+
opts[:fire_date] = NSDate.dateWithTimeIntervalSinceNow(opts[:fire_date])
|
33
|
+
end
|
34
|
+
|
35
|
+
notification = UILocalNotification.new.tap do |notif|
|
36
|
+
notif.alertAction = opts[:action]
|
37
|
+
notif.alertBody = opts[:body]
|
38
|
+
notif.alertLaunchImage = opts[:launch_image]
|
39
|
+
notif.applicationIconBadgeNumber = opts[:badge_number]
|
40
|
+
notif.timeZone = opts[:time_zone]
|
41
|
+
notif.fireDate = opts[:fire_date]
|
42
|
+
notif.hasAction = opts[:has_action]
|
43
|
+
notif.repeatCalendar = opts[:repeat][:calendar]
|
44
|
+
notif.repeatInterval = opts[:repeat][:interval]
|
45
|
+
notif.soundName = opts[:sound]
|
46
|
+
notif.userInfo = opts[:user_info]
|
47
|
+
end
|
48
|
+
UIApplication.sharedApplication.scheduleLocalNotification notification
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.reset
|
52
|
+
UIApplication.sharedApplication.tap do |app|
|
53
|
+
app.applicationIconBadgeNumber = 0
|
54
|
+
app.cancelAllLocalNotifications
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
data/lib/project/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion-takeoff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Rickert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- README.md
|
49
49
|
- lib/motion-takeoff.rb
|
50
50
|
- lib/project/messages.rb
|
51
|
+
- lib/project/reminders.rb
|
51
52
|
- lib/project/version.rb
|
52
53
|
homepage: https://www.github.com/MohawkApps/motion-takeoff
|
53
54
|
licenses:
|
@@ -73,5 +74,6 @@ rubygems_version: 2.0.3
|
|
73
74
|
signing_key:
|
74
75
|
specification_version: 4
|
75
76
|
summary: A RubyMotion specific iOS gem that helps you do things at launch. You can
|
76
|
-
use this gem to display messages at certain launch counts
|
77
|
+
use this gem to display messages at certain launch counts and remind users to use
|
78
|
+
your app.
|
77
79
|
test_files: []
|