motion-takeoff 0.0.4 → 0.0.5
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/README.md +20 -2
- data/lib/project/messages.rb +24 -1
- data/lib/project/version.rb +1 -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: b7becad65c8a7d0ea9ef00dbdbc2e27e97166643
|
4
|
+
data.tar.gz: 2032db9db7424eb048da9792e87c31fff7a76ac5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b32a72d25d07ddbb549d870be775e79f332ca9bb7d715d89d5a794b54e1fe07c685822e279f2c628732facc17f69099682f0f5331578131af5656e6e8d1cb05
|
7
|
+
data.tar.gz: f83ac94768809e355bb6ab9cca6a999a0a9e9677f3df6c25d66349286b7058bad5e8048d9d8ee3e7bbd982427951ca526c5d8f6ccc460cfd7c27f858f07466d1
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# motion-takeoff [](https://travis-ci.org/MohawkApps/motion-takeoff) [](https://codeclimate.com/github/MohawkApps/motion-takeoff) [](http://badge.fury.io/rb/motion-takeoff)
|
2
2
|
|
3
|
-
A RubyMotion specific iOS gem
|
3
|
+
A RubyMotion specific iOS gem for scheduling stuff. You can use motion-takeoff to display messages at certain launch counts and schedule local notifications. Currently, there are two 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
|
|
@@ -29,8 +29,26 @@ def applicationDidBecomeActive(application)
|
|
29
29
|
messages.takeoff
|
30
30
|
end
|
31
31
|
```
|
32
|
+
|
32
33
|
This will display an alert to the user on the 1st, 3rd, and 500th launches of the app.
|
33
34
|
|
35
|
+
### Asking for confirmation
|
36
|
+
|
37
|
+
You can use the Messages module to ask a user to do something. Just pass a `Proc` object to the `:action` option. You can send an array of strings using `:buttons` but it will default to `["Cancel", "OK"]`. When the user presses the "OK" button, the `Proc` will run.
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
def applicationDidBecomeActive(application)
|
41
|
+
messages = Takeoff::Messages.new
|
42
|
+
messages.schedule(
|
43
|
+
launch: 1,
|
44
|
+
title: "Welcome to #{App.name}!",
|
45
|
+
message: "So you want to view the settings?"
|
46
|
+
action: Proc.new{ App.delegate.viewController.showSettings }
|
47
|
+
)
|
48
|
+
messages.takeoff
|
49
|
+
end
|
50
|
+
```
|
51
|
+
|
34
52
|
## Usage: Reminder Module
|
35
53
|
|
36
54
|
The reminders module is a nice wrapper on `UILocalNotification` and makes it easy to schedule reminders to come back and use your app!
|
@@ -59,7 +77,7 @@ def applicationDidEnterBackground(application)
|
|
59
77
|
end
|
60
78
|
```
|
61
79
|
|
62
|
-
The `Takeoff::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
|
80
|
+
The `Takeoff::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 two options. Here's all the default options:
|
63
81
|
|
64
82
|
```ruby
|
65
83
|
{
|
data/lib/project/messages.rb
CHANGED
@@ -19,12 +19,35 @@ module Takeoff
|
|
19
19
|
def takeoff
|
20
20
|
self.messages.each do |message|
|
21
21
|
if message[:launch] == App::Persistence[@launch_key]
|
22
|
-
|
22
|
+
if message.keys.include? :action
|
23
|
+
confirm_alert message
|
24
|
+
else
|
25
|
+
regular_alert message
|
26
|
+
end
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
26
30
|
|
27
31
|
private
|
32
|
+
|
33
|
+
def regular_alert message
|
34
|
+
App.alert(message[:title], message:message[:message])
|
35
|
+
end
|
36
|
+
|
37
|
+
def confirm_alert message
|
38
|
+
message = {
|
39
|
+
:buttons => ["Cancel", "OK"]
|
40
|
+
}.merge(message)
|
41
|
+
|
42
|
+
alert = BW::UIAlertView.default(message) do |alert|
|
43
|
+
if alert.clicked_button.title == "OK"
|
44
|
+
message[:action].call
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
alert.show
|
49
|
+
end
|
50
|
+
|
28
51
|
def handle_launch
|
29
52
|
if App::Persistence[@launch_key].nil?
|
30
53
|
App::Persistence[@launch_key] = 1
|
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.5
|
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-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
- - '>'
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.0.0
|
41
|
-
description: A RubyMotion specific iOS gem
|
41
|
+
description: A RubyMotion specific iOS gem for scheduling stuff.
|
42
42
|
email:
|
43
43
|
- mjar81@gmail.com
|
44
44
|
executables: []
|
@@ -73,8 +73,7 @@ rubyforge_project:
|
|
73
73
|
rubygems_version: 2.0.3
|
74
74
|
signing_key:
|
75
75
|
specification_version: 4
|
76
|
-
summary: A RubyMotion specific iOS gem
|
77
|
-
|
78
|
-
your app.
|
76
|
+
summary: A RubyMotion specific iOS gem for scheduling stuff. You can use motion-takeoff
|
77
|
+
to display messages at certain launch counts and schedule local notifications.
|
79
78
|
test_files: []
|
80
79
|
has_rdoc:
|