ios - Swift 中的 Flurry 推送通知

标签 ios swift flurry

我正在使用 Flurry 尝试发送推送通知,Flurry 的所有其他元素(如分析、事件等)的教程都有 Swift 和 Obj-C,但是对于 Push 来说,所有元素都在 Obj-C 中。

我添加了 flurry ios sdk,一切正常,因为我可以在 flurry 网站上看到我的数据。

当它告诉我时,我陷入了困境

Include FlurryMessaging.h

如何在 Swift 中包含 .h 文件?

然后它要求我执行以下操作,但不是在 Swift 中

(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

//Step1 : Call the Integration API

[FlurryMessaging setAutoIntegrationForMessaging];

//Step2 (Optional): Get a callback

[FlurryMessaging setMessagingDelegate:self];

FlurrySessionBuilder* builder = [[[FlurrySessionBuilder alloc] withIncludeBackgroundSessionsInMetrics:YES];

[Flurry startSession:@”API_KEY” withOptions:launchOptions withSessionBuilder:builder];

return YES;

}

Implement the Delegate method for Received
-(void) didReceiveMessage:(nonnull FlurryMessage*)message

{

NSLog(@”didReceiveMessage = %@”, [message description]);

//App specific implementation

}

Implement the Delegate method for Clicked
-(void) didReceiveActionWithIdentifier:(nullable NSString*)identifier message:(nonnull FlurryMessage*)message

{

NSLog(@”didReceiveAction %@ , Message = %@”,identifier, [message description]);

//Any app specific logic goes here.

//Ex: Deeplink logic (loading of viewControllers (nibs or storboards),

//additional logging, etc

}

最佳答案

如果您通过 Cocoapods 进行集成,请确保在您的 podfile 中包含“Flurry-iOS-SDK/FlurryMessaging”。如果有,那么您可以通过将其添加到导入语句来访问消息传递方法:

导入Flurry_iOS_SDK

然后设置自动集成:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

FlurryMessaging.setAutoIntegrationForMessaging()
FlurryMessaging.setMessagingDelegate(self)

//And set up your Builder:

let builder = FlurrySessionBuilder.init()

    .withIncludeBackgroundSessionsInMetrics(true)

Flurry.startSession("YOUR_API_KEY", with: builder)
return true
}

实现 Received 的委托(delegate)方法

func didReceive(_ message: FlurryMessage) {
    print("Did Receive Message")
    //App specific implementation
}

实现 Clicked 的委托(delegate)方法

func didReceiveAction(withIdentifier identifier: String?, message: FlurryMessage) {
    print("Message Clicked")
    //Any app specific logic goes here.
}

关于ios - Swift 中的 Flurry 推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50490712/

相关文章:

ios - 带有迦太基的 sqlite.swift

ios - 测试此字符串初始化方法是否将字符串更改为不同的语言?

ios - 使用 uipresentviewcontroller 显示 uiviewcontroller 时,状态栏与导航栏重叠

ios - iOS UI 自动脚本错误 "Cannot perform action on invalid element: UIAElementNil from target.frontMostApp().mainWindow().buttons()[0]"

swift - 使用 swift 4 在波轮下查看图像

ios - 仅当水平滚动至少是垂直滚动的 2 倍时,才开始在 UITableView 中水平滚动 UIScrollView

android - 程序类型已经存在:com.flurry.android.Consent

ios - Flurry 依赖分析警告

ios - Flurry - 用户获取分析 (UAA) - 无安装

objective-c - 在IOS中发出http请求并从返回的json对象中解析特定数据