Swift 2.0 OneSignal .pushNotification

Swift 2.0 OneSignal .pushNotification

你好,我打算设置一个功能,当我需要触发时,从应用程序向每个下载的应用程序发送推送通知,所以功能是;

func notification(debug:Bool,content:String){
    let pushContent:[NSObject : AnyObject] = ["app_id" : [""], "contents": ["en": content]]

    OneSignal.postNotification(pushContent)
}

错误是 对成员的引用不明确 'postNotification'

我查看了 API 参考资料,他们给出了这样的示例,但效果不佳

OneSignal.postNotification(["contents": ["en": "Test Message"], "include_player_ids": ["3009e210-3166-11e5-bc1b-db44eb02b120"]])

错误是'(dictionaryLiteral: (NSObject, AnyObject), (NSObject, AnyObject))' is not convertible to '(dictionaryLiteral: (NSString, NSObject)...)', tuples have不同数量的元素

我怎样才能完成这项工作?

是的,它是最新的 使用 OneSignal (1.13.2)

postNotification 大多数 OneSignal 函数都是实例函数。您将需要使用从 didFinishLaunchingWithOptions 创建的相同实例或使用 OneSignal.defaultClient() 助手来获取当前实例。

示例:

OneSignal.defaultClient().postNotification(["contents": ["en": "Test Message"], "include_player_ids": ["3009e210-3166-11e5-bc1b-db44eb02b120"]])