本文整理汇总了TypeScript中web-push.sendNotification函数的典型用法代码示例。如果您正苦于以下问题:TypeScript sendNotification函数的具体用法?TypeScript sendNotification怎么用?TypeScript sendNotification使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sendNotification函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1:
subscriptions.forEach(subscription => {
const pushSubscription = {
endpoint: subscription.endpoint,
keys: {
auth: subscription.auth,
p256dh: subscription.publickey
}
};
push.sendNotification(pushSubscription, JSON.stringify({
type, body
})).catch((err: any) => {
//console.log(err.statusCode);
//console.log(err.headers);
//console.log(err.body);
if (err.statusCode == 410) {
Subscription.remove({
userId: userId,
endpoint: subscription.endpoint,
auth: subscription.auth,
publickey: subscription.publickey
});
}
});
});
开发者ID:ha-dai,项目名称:Misskey,代码行数:26,代码来源:push-sw.ts
示例2: sendPush
export function sendPush(subscription: any, payload?: Object): Promise<any> {
return push.sendNotification(subscription, JSON.stringify(payload), {
vapidDetails: {
subject: 'mailto:[email protected]',
publicKey: 'BLRl_fG1TCTc1D2JwzOpdZjaRcJucXtG8TAd5g9vuYjl6KUUDxgoRjQPCgjZfY-_Rusd_qtjNvanHXeFvOFlxH4',
privateKey: 't3JtFOflouvPUxFKeSSmZdjuVidnD_0dNGFM1v-N4PI',
},
});
}
开发者ID:madhu-amrit,项目名称:mobile-toolkit,代码行数:9,代码来源:push.ts
示例3: sendPush
export function sendPush(reg: any, payload?: Object): Promise<any> {
let endpoint = reg.url;
return push.sendNotification(endpoint, {
userPublicKey: reg.key,
userAuth: reg.auth,
payload: new Buffer(JSON.stringify(payload))
});
}
开发者ID:SuperSoe,项目名称:mobile-toolkit,代码行数:9,代码来源:push.ts
示例4: sendNotification
// $ExpectType "POST"
requestDetails.method;
// $ExpectType Headers
requestDetails.headers;
// $ExpectType Buffer
requestDetails.body;
// $ExpectType string
requestDetails.endpoint;
// $ExpectType string | undefined
requestDetails.proxy;
// ====================
// sendNotification()
// ====================
// $ExpectType Promise<SendResult>
sendNotification(pushSubscription, 'payload', requestOptions);
// Buffers are also supported
// $ExpectType Promise<SendResult>
sendNotification(pushSubscription, buffer);
// $ExpectType Promise<SendResult>
sendNotification(pushSubscription, buffer, requestOptions);
// Payload can be absent or null
// $ExpectType Promise<SendResult>
sendNotification(pushSubscription);
// $ExpectType Promise<SendResult>
sendNotification(pushSubscription, null, requestOptions);
// PushSubscription must have all its values
// $ExpectError
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:31,代码来源:web-push-tests.ts
示例5: function
app.post(route + 'sendNotification', function (req, res : express.Response) {
webPush.sendNotification(req.query.endpoint, 0).then(function () {
res.status(201).end();
});
});
开发者ID:isra-fel,项目名称:push-demo,代码行数:5,代码来源:pushts.ts
注:本文中的web-push.sendNotification函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论