NW Pusher Push PayLoad - iOS Swift

2020-07-26 12:09发布

问题:

i am getting the error

'can't invoke the push pay load with the argument list of types (NSString , token : NSString ,identifier:int32 error :inout NSError?)'

for the below line

    var error:NSError? = nil
    var Pusher:NWPusher = NWPusher.connectWithPKCS12Data(PKS12,password:"as",error: &error)
    println(Pusher)
    var payLoad:NSString = "{\"aps\":{\"alert\":\"Testing From Swift App\"}}";
    var token:NSString = "token string here"
    var PayLoaderror:NSErrorPointer? = nil
    var pushed:Bool = Pusher.pushPayload(payLoad, token: token, identifier:rand() ,error: &error)

回答1:

var error:NSError? = nil 
var Pusher:NWPusher = NWPusher.connectWithPKCS12Data(PKS12,password:"as",error: &error) 
println(Pusher) 
var payLoad:NSString = "{\"aps\":{\"alert\":\"Testing From Swift App\"}}"
var token:NSString = "Token here" 

// here is my new line of code
//
// also make certain Int32 is capitalized; case sensitivity matters!
let identifier = rand() as Int32

let pushed = Pusher.pushPayload(payLoad, token: token, identifier: identifier ,error: &error)


标签: ios swift