谷歌分析与iOS,数据不发送

时间:2023-01-16 15:18:54

So I've integrated Google Analytics in my app and everything seems to be running smoothly, but the data does not get sent from my app to Google. I've imported all the header files and the frameworks, but the information won't send.

所以我把谷歌分析整合到我的app中,一切似乎都运行得很顺利,但是数据并没有从我的app发送到谷歌。我已经导入了所有的头文件和框架,但是信息不会发送。

My delegate-file looks like this:

我的委托文件是这样的:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    GAI.sharedInstance().trackUncaughtExceptions = true
    GAI.sharedInstance().dispatchInterval = 20
    GAI.sharedInstance().trackerWithTrackingId("my-secret-id")

    return true
}

And then I'm trying to send an event in my viewDidLoad, like this:

然后我试着在viewDidLoad发送一个事件,像这样:

    let tracker: GAITracker = GAI.sharedInstance().defaultTracker

    tracker.send(GAIDictionaryBuilder.createEventWithCategory("demo_cat", action: "press_button", label: "demo_label", value: nil).build() as [NSObject : AnyObject])

but nothing happens. I can't find out what other steps I need to complete for it to work.

但什么都没发生。我不知道我还需要完成哪些步骤才能让它工作。

Any suggestions on how to proceed would be appreciated.

如能就如何进行提出建议,我们将不胜感激。

1 个解决方案

#1


1  

Just try to send this code

试着发送这段代码

let tracker: GAITracker = GAI.sharedInstance().defaultTracker
tracker.send(GAIDictionaryBuilder.createEventWithCategory("demo_cat", action: "press_button", label: "demo_label", value: nil).build() as [NSObject : AnyObject])

In viewDidAppear() method, so that event can trigger after view get completely loaded. In viewDidLoad() method could not send event, at the time view is getting ready.

在viewDidAppear()方法中,可以在视图完全加载后触发事件。在viewDidLoad()方法中,无法发送事件,此时视图正在准备就绪。

May this help you.

这可以帮助你。

HTH, Enjoy Coding !!

HTH,享受编码!

#1


1  

Just try to send this code

试着发送这段代码

let tracker: GAITracker = GAI.sharedInstance().defaultTracker
tracker.send(GAIDictionaryBuilder.createEventWithCategory("demo_cat", action: "press_button", label: "demo_label", value: nil).build() as [NSObject : AnyObject])

In viewDidAppear() method, so that event can trigger after view get completely loaded. In viewDidLoad() method could not send event, at the time view is getting ready.

在viewDidAppear()方法中,可以在视图完全加载后触发事件。在viewDidLoad()方法中,无法发送事件,此时视图正在准备就绪。

May this help you.

这可以帮助你。

HTH, Enjoy Coding !!

HTH,享受编码!