วันอังคารที่ 24 พฤษภาคม พ.ศ. 2559

Config Paser server ให้สามารถ ส่ง push ได้

index.js
var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'myAppId',
  masterKey: process.env.MASTER_KEY || '', //Add your master key here. Keep it secret!
  // fileKey: 'XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
  serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse',  // Don't forget to change to https if needed
  liveQuery: {
    classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
  },
  push: {   
    android: {
        senderId: '...',
        apiKey: '...'
      },
    ios: [
      {
        pfx: 'xxx.p12',  // ชือ file .p12
        bundleId: 'xx.xxx',  // ชือ package name
        production: false
      }
    ]
  }
});

Test send push 
curl -X POST \
  -H "X-Parse-Application-Id: ${APPLICATION_ID}" \
  -H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
        "where": {
          "deviceType": "ios"
        },
        "data": {
          "alert": "Hello World!"
        }
      }' \
  https://api.parse.com/1/push

ไม่มีความคิดเห็น:

แสดงความคิดเห็น