简体   繁体   English

Swift中的Flurry Push通知

[英]Flurry Push Notifications in Swift

I'm using Flurry to try to send push notifications, the tutorial for all other elements of Flurry like analytics, events etc all have Swift and Obj-C however for Push its all in Obj-C. 我正在使用Flurry尝试发送推送通知,有关Flurry的所有其他元素(如分析,事件等)的教程均具有Swift和Obj-C,但是对于在Obj-C中进行全部推送都是如此。

I've got the flurry ios sdk added and everything works well because I can see my data on the flurry site. 我已经添加了flurry ios sdk,并且一切正常,因为我可以在flurry站点上查看我的数据。

I'm stuck at this point when it tells me to 当它告诉我

Include FlurryMessaging.h 包括FlurryMessaging.h

How do I include a .h file in Swift? 如何在Swift中包含.h文件?

It then asks me to do the following but its not in Swift 然后它要求我执行以下操作,但不能在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

}

If you are integrating through Cocoapods, make sure to include 'Flurry-iOS-SDK/FlurryMessaging'in your podfile. 如果要通过Cocoapods进行集成,请确保在Podfile中包含“ Flurry-iOS-SDK / FlurryMessaging”。 If you have, then you can access the Messaging methods by adding this to your import statements: 如果有的话,可以通过将其添加到导入语句中来访问Messaging方法:

import Flurry_iOS_SDK 导入Flurry_iOS_SDK

Then set auto integration: 然后设置自动集成:

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
}

Implement the Delegate method for Received 实现接收的委托方法

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

Implement the Delegate method for Clicked 实现Clicked的Delegate方法

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM