Azure 通知中心如何向 nodejs 注册 Id?

Azure Notification hub how to register Id with nodejs?

你好,我想用 Nodejs 创建注册 ID 可以做什么?

我尝试发送通知,但我需要注册 Id

var azure = require('azure-sb');



 var notificationHubService = azure.createNotificationHubService('hubname','');



var payload={
       alert: 'Hello test!'
  };
  notificationHubService.apns.send(null, payload, function(error){
  if(!error){
      // notification sent
  }
});

要创建注册,您需要执行以下操作来创建注册:

  const CONNECTION_STRING = '<Listen Connection String>';
  const HUB_NAME = 'Notification Hub Name';

  const APNS_TOKEN = 'APNS Client Token';
  const SAMPLE_TAG = 'language_en';

  const service = new NotificationHubService(HUB_NAME, CONNECTION_STRING);

  service.apns.createNativeRegistration(APNS_TOKEN, SAMPLE_TAG, (err, response) => {
    if (err) {
      console.log(err);
      return;
    }

    console.log('Registration success');
    console.log(JSON.stringify(response));
  });