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