【发布时间】:2015-12-14 20:25:57
【问题描述】:
当用户收到消息时,我正在尝试让我的应用发送带有自定义声音文件的通知,但 var pushData:NSDictionary = NSDictionary(dictionaryLiteral: "New Message "+myName,"alert","KeepNotification.wav","sound") 中出现错误
Xcode 说:无法使用类型为 '(dictionaryLiteral: String, String, String, String)' 的参数列表调用类型 'NSDictionary' 的初始化程序
我不知道这意味着什么,所以如果有人向我展示了正确的代码行,我将不胜感激。
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 { ... }”就足够了
-
请使用更具描述性的问题标题。
标签: ios swift parse-platform