2016-05-03 22:50:21 +00:00
|
|
|
// Copyright IBM Corp. 2013,2016. All Rights Reserved.
|
|
|
|
// Node module: loopback
|
|
|
|
// This file is licensed under the MIT License.
|
|
|
|
// License text available at https://opensource.org/licenses/MIT
|
|
|
|
|
2016-11-15 21:46:23 +00:00
|
|
|
'use strict';
|
2016-09-16 19:31:48 +00:00
|
|
|
var g = require('../../lib/globalize');
|
2013-07-12 20:09:22 +00:00
|
|
|
var models = require('../../lib/models');
|
2013-07-16 17:42:47 +00:00
|
|
|
var loopback = require('../../');
|
|
|
|
var app = loopback();
|
2013-07-12 20:09:22 +00:00
|
|
|
|
2013-07-16 17:42:47 +00:00
|
|
|
app.use(loopback.rest());
|
2013-07-12 20:09:22 +00:00
|
|
|
|
2016-11-15 21:46:23 +00:00
|
|
|
var dataSource = loopback.createDataSource('db', {connector: loopback.Memory});
|
2013-07-12 20:09:22 +00:00
|
|
|
|
|
|
|
var Application = models.Application(dataSource);
|
|
|
|
|
|
|
|
app.model(Application);
|
|
|
|
|
2016-12-06 14:40:42 +00:00
|
|
|
var data = {
|
|
|
|
pushSettings: [{
|
|
|
|
'platform': 'apns',
|
|
|
|
'apns': {
|
|
|
|
'pushOptions': {
|
|
|
|
'gateway': 'gateway.sandbox.push.apple.com',
|
|
|
|
'cert': 'credentials/apns_cert_dev.pem',
|
|
|
|
'key': 'credentials/apns_key_dev.pem',
|
|
|
|
},
|
|
|
|
|
|
|
|
'feedbackOptions': {
|
|
|
|
'gateway': 'feedback.sandbox.push.apple.com',
|
|
|
|
'cert': 'credentials/apns_cert_dev.pem',
|
|
|
|
'key': 'credentials/apns_key_dev.pem',
|
|
|
|
'batchFeedback': true,
|
|
|
|
'interval': 300,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}],
|
|
|
|
};
|
2013-07-12 20:09:22 +00:00
|
|
|
|
|
|
|
Application.create(data, function(err, data) {
|
2016-06-07 14:48:28 +00:00
|
|
|
g.log('Created: %s', data.toObject());
|
2013-07-12 20:09:22 +00:00
|
|
|
});
|
|
|
|
|
2016-11-15 21:46:23 +00:00
|
|
|
Application.register('rfeng', 'MyApp', {description: g.f('My first mobile application')},
|
2016-04-01 09:14:26 +00:00
|
|
|
function(err, result) {
|
|
|
|
console.log(result.toObject());
|
2013-07-12 20:09:22 +00:00
|
|
|
|
2016-04-01 09:14:26 +00:00
|
|
|
result.resetKeys(function(err, result) {
|
2016-08-04 21:26:01 +00:00
|
|
|
console.log(result.toObject());
|
2016-04-01 09:14:26 +00:00
|
|
|
});
|
2013-07-12 20:09:22 +00:00
|
|
|
});
|