【问题标题】:Swift 2.0 OneSignal .pushNotificationSwift 2.0 OneSignal .pushNotification
【发布时间】:2016-05-27 17:06:44
【问题描述】:

您好,我打算设置一个函数,以便在我需要触发该函数时从应用程序向每个下载的应用程序发送推送通知;

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"]])

error is '(dictionaryLiteral: (NSObject, AnyObject), (NSObject, AnyObject))' 不能转换为 '(dictionaryLiteral: (NSString, NSObject)...)',元组有不同数量的元素

我怎样才能使这项工作?

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

【问题讨论】:

    标签: ios swift api push-notification onesignal


    【解决方案1】:

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

    例子:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-04
      • 1970-01-01
      相关资源
      最近更新 更多