spns 0.2.15 → 0.2.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +65 -16
  2. data/VERSION +1 -1
  3. data/spns.yml +2 -2
  4. metadata +6 -5
data/README.md CHANGED
@@ -1,38 +1,39 @@
1
1
  spns
2
2
  =======
3
- Simple Push Notification Server written with Sinatra and Sequel(Sqlite3)
3
+ ###Simple Push Notification Server written with Ruby/Sinatra and Sequel(Sqlite3)###
4
4
 
5
5
  Feature:
6
6
  =======
7
7
 
8
- 1. rubygem, simple to install.
9
- 2. provide pem file is the only requirement.
10
- 3. no need to setup database, using sqlite3.
11
- 4. provide default config file(spns.yml) with default value.
8
+ ###1. 'spns' is a rubygem, simple to install.###
9
+ ###2. only need to provide pem file.###
10
+ ###3. no need to setup database(using sqlite3).###
11
+ ###4. provide default config file(spns.yml) with default value.###
12
12
 
13
- Requirement
13
+ Sqlite3 Installation
14
14
  =======
15
15
 
16
- Sqlite3
17
- -------
18
-
19
16
  CentOS/Redhat:
17
+ -------
20
18
 
21
19
  $ yum install sqlite3
22
20
 
23
21
  Debian/Ubuntu:
22
+ -------
24
23
 
25
24
  $ apt-get install sqlite3
26
25
 
27
26
  FreeBSD:
27
+ -------
28
28
 
29
29
  $ cd /usr/ports/databases/sqlite34
30
30
  $ sudo make install clean
31
31
 
32
32
  Mac:
33
+ -------
33
34
 
34
- $ brew install sqlite3 # Homebrew
35
- $ port install sqlite3 # Macport
35
+ $ brew install sqlite # Homebrew
36
+ $ port install sqlite # Macport
36
37
 
37
38
  Installation
38
39
  =======
@@ -41,16 +42,64 @@ Installation
41
42
 
42
43
  Usage
43
44
  =======
44
- 1. under the current directory, provide single pem file combined with certificate and key, HOWTO ([Check this link](http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12))
45
+ ###1. under the current directory, provide single pem file combined with certificate and key(name pattern: appid_mode.pem), HOWTO ([Check this link](http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12))###
45
46
 
46
- 2. edit spns.yml. (when you run spns first time, it will generate this file) ([Check this link](https://raw.github.com/eiffelqiu/spns/master/spns.yml))
47
+ ###2. edit spns.yml. (when you run spns first time, it will generate this file) ([Check this link](https://raw.github.com/eiffelqiu/spns/master/spns.yml))###
47
48
 
48
- 3. provide a cron script under current directory, default named "cron" according to spns.yml
49
+ port: 4567 ## SPNS server port, default is sinatra's port number: 4567
50
+ mode: development ## 'development' or 'production' mode, you should provide pem file ({appid}_{mode}.pem) accordingly(such as, app1_development.pem, app1_production.pem).
51
+ cron: cron ## cron job file name, SPNS server will generate a demo 'cron' file for demostration only in current directory.
52
+ timer: 0 # how often you run the cron job, unit: minute. when set with 0, means no cron job execute.
53
+ apps:
54
+ - app1 ## appid you want to supprt APNS, SPNS Server can give push notification support for many iOS apps, just list the appid here.
49
55
 
50
- 4. start spns server, default port is 4567(sinatra's default port)
56
+ ###3. start spns server, default port is 4567(sinatra's default port)###
51
57
 
52
58
  ![spns usage](https://raw.github.com/eiffelqiu/spns/master/doc/capture1.png)
53
59
 
60
+
61
+ FAQ:
62
+ =======
63
+
64
+ 1. How to register notification? (Client Side)
65
+ -------
66
+
67
+ ###In AppDelegate file, add methods below to register device token###
68
+
69
+ - (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
70
+ {
71
+ NSString * tokenAsString = [[[deviceToken description]
72
+ stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]]
73
+ stringByReplacingOccurrencesOfString:@" " withString:@""];
74
+ NSString *urlAsString = [NSString stringWithFormat:@"http://serverIP:4567/v1/apps/app1/%@", token];
75
+ NSURL *url = [NSURL URLWithString:urlAsString];
76
+ NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url];
77
+ [urlRequest setTimeoutInterval:30.0f];
78
+ [urlRequest setHTTPMethod:@"GET"];
79
+ NSOperationQueue *queue = [[[NSOperationQueue alloc] init] autorelease];
80
+ [NSURLConnection sendAsynchronousRequest:urlRequest queue:queue completionHandler:nil];
81
+ }
82
+
83
+ - (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
84
+ {
85
+ NSLog(@"Failed to get token, error: %@", error);
86
+ }
87
+
88
+ 2. How to send push notification? (Server Side)
89
+ -------
90
+
91
+ ###run **curl** command to send push notification message, whatever shell.###
92
+
93
+ $ curl http://localhost:4567/v1/apps/app1/push/{message}/{pid}
94
+
95
+ ###Note:###
96
+
97
+ ###param1 (message): push notification message you want to send, remember the message should be html escaped###
98
+
99
+ ###param2 (pid ): unique string to mark the message, for example current timestamp or md5/sha1 digest###
100
+
101
+
102
+
54
103
  Contributing to spns
55
104
  =======
56
105
 
@@ -65,5 +114,5 @@ Contributing to spns
65
114
  Copyright
66
115
  =======
67
116
 
68
- Copyright (c) 2012 Eiffel Qiu. See LICENSE.txt for further details.
117
+ ###Copyright (c) 2012 Eiffel Qiu. See LICENSE.txt for further details.###
69
118
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.15
1
+ 0.2.16
data/spns.yml CHANGED
@@ -1,6 +1,6 @@
1
- port: 4567
1
+ port: 54188
2
2
  mode: development
3
3
  cron: cron
4
- timer: 0 # minute
4
+ timer: 0
5
5
  apps:
6
6
  - app1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.15
4
+ version: 0.2.16
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-13 00:00:00.000000000 Z
12
+ date: 2012-09-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sqlite3
@@ -314,7 +314,8 @@ files:
314
314
  - cron
315
315
  - lib/spns.rb
316
316
  - spns.yml
317
- - bin/spns
317
+ - !binary |-
318
+ YmluL3NwbnM=
318
319
  homepage: http://github.com/eiffelqiu/spns
319
320
  licenses:
320
321
  - MIT
@@ -330,7 +331,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
330
331
  version: '0'
331
332
  segments:
332
333
  - 0
333
- hash: 1342246939591537697
334
+ hash: 2005448441526104093
334
335
  required_rubygems_version: !ruby/object:Gem::Requirement
335
336
  none: false
336
337
  requirements:
@@ -339,7 +340,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
339
340
  version: '0'
340
341
  requirements: []
341
342
  rubyforge_project: spns
342
- rubygems_version: 1.8.24
343
+ rubygems_version: 1.8.21
343
344
  signing_key:
344
345
  specification_version: 3
345
346
  summary: Simple Push Notification Server