小编Chr*_*lez的帖子

当我的应用处于后台或关闭时远程推送通知到达时从有效负载获取数据

我需要在重新发送远程推送通知时从有效负载中捕获数据,在IOS 9上我使用func执行此操作:didReceiveRemoteNotification在IOS 10上使用swift 3.0我实现了这两个功能.

@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)
{
print("\(notification.request.content.userInfo)")

completionHandler([.alert, .badge, .sound])
}

@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)
{
print("User Info = ",response.notification.request.content.userInfo)

completionHandler()
}
Run Code Online (Sandbox Code Playgroud)

第二个功能仅在用户触摸推送时执行

当我的应用程序处于后台甚至关闭时,我需要在推送通知到达时捕获数据.

问候.问候

ios swift swift3

6
推荐指数
1
解决办法
2342
查看次数

如何返回Azure函数的结果

我从Azure函数开始。我有以下代码:

module.exports = function (context, req) 
    {
        context.log('JavaScript HTTP trigger function processed a request.');

        context.log(context.req.body.videoId)
        if (context.req.body.videoId =! null) 
        {
            context.log('inicia a obtener comentarios')

             const fetchComments = require('youtube-comments-task')

            fetchComments(req.body.videoId)
            .fork(e => context.log('ERROR', e), p => {                   
                        context.log('comments', p.comments)
                        })        

             context.res = { body: fetchComments.comments }
        }
        else {
            context.res = {
                status: 400,
                body: "Please pass a videoId on the query string or in the   request body"
            };
        }
        context.done();
};
Run Code Online (Sandbox Code Playgroud)

如何返回fetchComments返回的JSON?

javascript azure node.js azure-functions

2
推荐指数
1
解决办法
1286
查看次数

标签 统计

azure ×1

azure-functions ×1

ios ×1

javascript ×1

node.js ×1

swift ×1

swift3 ×1