Xcode说:无法调用初始值设定项我试图使我的应用程序发送通知与自定义声音文件,当用户收到消息,但有一个错误var pushData:NSDictionary = NSDictionary(dictionaryLiteral: "New Message "+myName,"alert","KeepNotification.wav","sound")
Xcode说:类型'NSDictionary'类型'(字典文件:字符串,字符串,字符串,字符串)的参数列表'Swift 2.0问题显示通知与自定义声音文件
我不知道这意味着什么,所以我会很感激,如果有人向我展示正确的代码行。
if success == true {
//This to push notification when message is sent successful with sound ********
var myName = PFUser.currentUser().valueForKey("profileName") as! String
var pushData:NSDictionary = NSDictionary(dictionaryLiteral: "New Message "+myName,"alert","KeepNotification.wav","sound")
var uQuery:PFQuery = PFUser.query()
uQuery.whereKey("username", equalTo: otherName)
var pushQuery:PFQuery = PFInstallation.query()
pushQuery.whereKey("user", matchesQuery: uQuery)
var push:PFPush = PFPush()
push.setQuery(pushQuery)
push.setData(pushData as [NSObject : AnyObject])
push.sendPushInBackgroundWithBlock{
(success:Bool! , error:NSError!) -> Void in
}
print("Push Sent")
//-----------------------------------------------------------------
print("Message Sent" + myName)
self.messageTextView.text = ""
self.mLabel.hidden = false
self.refreshResullts()
}
}
}
}
谢谢,如果有什么不清楚的地方,我会编辑我的问题。
请注意,编写“if success {...}”已足够 –
请使用更具描述性的问题标题。 – NRitH