summaryrefslogtreecommitdiff
path: root/examples/lib/okpush/index.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2016-10-05 20:37:36 -0400
committerJules Laplace <jules@okfoc.us>2016-10-05 20:37:36 -0400
commitef2cfac2c055cdfa3958374c68a8d0cfe4e4f046 (patch)
treeb8808d63300e7517d0aa0ba4232bb6281e5afd8e /examples/lib/okpush/index.js
parentae843591da0fea1a57684f26737be0b484718809 (diff)
fixing stuff for node-apn v2
Diffstat (limited to 'examples/lib/okpush/index.js')
-rw-r--r--examples/lib/okpush/index.js34
1 files changed, 22 insertions, 12 deletions
diff --git a/examples/lib/okpush/index.js b/examples/lib/okpush/index.js
index e8b6549..a39cd35 100644
--- a/examples/lib/okpush/index.js
+++ b/examples/lib/okpush/index.js
@@ -1,8 +1,10 @@
/**
*/
-var OKTemplate = require('../../../app/node_modules/oktemplate')
+var path = require('path')
var passport = require('passport')
+var DigestStrategy = require('passport-http').DigestStrategy;
+var OKTemplate = require('../../../app/node_modules/oktemplate')
var apn = require('./apn')
var db = require('./db')
@@ -23,7 +25,9 @@ function OKPush (options) {
if (!options.config)
throw new Error('Configuration not provided to OKPush')
if (!options.config.notifications)
- throw new Error('Notifications not defined in OKPush')
+ throw new Error('Notifications not provided to OKPush')
+ if (!options.config.bundleId)
+ throw new Error('bundleId not provided to OKPush')
var express = options.express
var router = express.Router()
@@ -31,7 +35,7 @@ function OKPush (options) {
var meta = options.meta
var error = options.errorHandler
// var okcms_db = options.db
-
+
var templateProvider = this._templateProvider = new OKTemplate({
root: path.join(__dirname, './templates'),
debug: meta.debug
@@ -39,14 +43,20 @@ function OKPush (options) {
var templates = {}
templates['index'] = templateProvider.getTemplate('index')
-
- apn.init()
- db.init()
- router.use('/admin/', passport.initialize())
- router.all('/admin/(:path*)?', passport.authenticate('digest', {
- session: false
- }))
+ apn.init(config)
+ db.init(config)
+
+// router.use('/admin/', passport.initialize())
+// router.all('/admin/(:path*)?', passport.authenticate('digest', {
+// session: false
+// }))
+
+ var notifications = {}
+ Object.keys(options.config.notifications).forEach(function(key){
+ var opt = options.config.notifications[key]
+ var note = apn.buildPayload(opt, options.config.bundleId)
+ })
// pass in admin middleware!
router.get('/admin/', function (req, res) {
@@ -71,8 +81,8 @@ function OKPush (options) {
this._router = router
}
-OKExample.prototype.middleware = function () {
+OKPush.prototype.middleware = function () {
return this._router
}
-module.exports = OKExample
+module.exports = OKPush