簡體   English   中英

Swift中的Flurry Push通知

[英]Flurry Push Notifications in Swift

我正在使用Flurry嘗試發送推送通知,有關Flurry的所有其他元素(如分析,事件等)的教程均具有Swift和Obj-C,但是對於在Obj-C中進行全部推送都是如此。

我已經添加了flurry ios sdk,並且一切正常,因為我可以在flurry站點上查看我的數據。

當它告訴我

包括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”。 如果有的話,可以通過將其添加到導入語句中來訪問Messaging方法:

導入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
}

實現接收的委托方法

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.
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM