小编Sha*_*n C的帖子

使用FCM进行IOS数据通知

我正在使用FCM(firebase云消息传递)向IOS应用程序发送"自定义"数据通知.据我所知,当您希望FCM处理代表您的应用程序显示通知时,我们会使用通知消息.当您只想在应用中处理消息时,我们会使用数据消息.这是设计的.

我面临的问题是,Device/InstandID令牌对于已安装的应用程序是唯一的,而不是登录应用程序的用户.因此,要解决此问题,我将在数据中发送预期的用户标记,以便它成为数据消息.由于应用程序处理数据通知,因此只有在打开应用程序并且仅显示通知时才会触发didReceiveRemoteNotification()回调,而不会立即显示通知.

我的问题是,我是否可以发送自定义数据通知消息,即使应用程序关闭也会立即显示.

这是我发送给FCM的有效负载:

{
    registeration_ids : [<id_1>, <id_2>],
    data : {
        title   : message_title,
        body    : message_body, 
        intended_user : message_user
    }
}
Run Code Online (Sandbox Code Playgroud)

在Android FirebaseMessagingService.onMessageReceived()中调用即使应用程序在后台但在ios didReceiveRemoteNotification()中仅在启动应用程序时调用,因此如果发送数据消息则不会显示后台消息.

iphone notifications ios firebase firebase-cloud-messaging

11
推荐指数
4
解决办法
3万
查看次数

在 Alamofire 4 中使用 SwiftyJson 为 MultipartFormData 请求创建 JSON 数据

我需要使用 Alamofire 4 发送 MultipartFormData .Post 请求。

需要发送 JSON 和文件数据。

我很难将 SwiftyJson 对象转换为类型 Data 对象。

SwiftyJSON 看起来像这样:

var json: JSON = JSON([ "Name" : "Ben", "UserID" : 2, "Username" : "benji"])
Run Code Online (Sandbox Code Playgroud)

Alamofire 4 请求看起来像这样

service.upload(multipartFormData: { (MultipartFormData) in
            MultipartFormData.append(userData, withName: "userInfo")
            MultipartFormData.append(fileUrl, withName: "File")    
            }, to: url) { (encodingResult) in
                switch encodingResult {
                case .success(let upload, _, _):
                    upload.responseJSON { response in
                        debugPrint(response)
                    }
                case .failure(let encodingError):
                    print(encodingError)
                }
            }
Run Code Online (Sandbox Code Playgroud)

我的问题是如何将 SwiftyJson 对象转换为类型数据,以便将其附加到 mutlipartformdata?我尝试了以下操作,但它们似乎不起作用,而且我无法在网上找到解决方案:

json.rawData()
json.rawString?.data(using: String.Encoding.utf8)
Run Code Online (Sandbox Code Playgroud)

multipartform-data ios alamofire swifty-json swift3

3
推荐指数
1
解决办法
2619
查看次数

haskell函数声明

我在理解Haskell函数的签名/参数/输入时遇到问题.在有人抱怨之前,是的,我已经完成了我的研究,但似乎无法找到一个好的答案或解释.

基本上我有一个功能:

update :: Eq a => (a->b) -> b -> a -> (a->b)

我如何理解(a-> b) - > b - > a - >(a-> b)?我认为它是一个函数的输入后跟2个值并输出一个函数??

我有2个不同的函数,它们做同样的事情,一个使用3个参数,一个使用4个但是标题(函数的参数)是相同的.

(1)

update :: Eq a => (a->b) -> b -> a -> (a->b)
update s v x y = if x==y then v else s y
Run Code Online (Sandbox Code Playgroud)

(2)

update :: Eq a => (a->b) -> b -> a -> (a->b)
update s v y = ss
  where ss x = if ( x == y …
Run Code Online (Sandbox Code Playgroud)

haskell declaration function

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