开发者

Google Analytics for iOS not dispatching events

开发者 https://www.devze.com 2023-03-30 18:23 出处:网络
I\'m using the latest SDK version, and the basic code to register and send a page view: [[GANTracker sharedTracker] startTrackerWithAccountID:@\"UA-MY_ACCOUNT_ID-1\"

I'm using the latest SDK version, and the basic code to register and send a page view:

[[GANTracker sharedTracker] startTrackerWithAccountID:@"UA-MY_ACCOUNT_ID-1"
                                           dispatchPeriod:10
                                                 delegate:self];

NSError *error;

if (![[GANTracker sharedTracker] trackPageview:@"/firstpage"
                                     withError:&error]) {
  NSLog(@"tracker failed: %@",error);
}

However the events are not dispatched from the device or simulator. There are no errors as well. When i turn on the debug flag, i can see the following:

dispatch called
dispatching 4 events
[after 10 seconds]
dispatch called
...dispatcher was busy
[after 10 seconds]
dispatch called
...dispatcher was busy

My delegate method never gets called:

- (void)trackerDispatchDidComplete:(GANTracker *)tracker
                  eventsDispatched:(NSUInteger)eventsDispatched
              eventsFailedDispatch:(NSUInteger)eventsFailedDispatch{
    NSLog(@"success: %d failures: %d",eventsDispatched,event开发者_开发技巧sFailedDispatch);
}
  • I tried to create a new publisher ID but it did not help as well.
  • I do have internet connection from the device and simulator
  • I deleted the app before trying.
  • I played with the dispatch period - setting it to -1 and call the dispatch manually

Nothing helped.... :(

I'm struggling with this for a day now... how can i make it work?


I had the same problem with the dispatcher ("...dispatcher was busy"). In my case, it was because I had run my app normally in the background, and it was using the dispatcher. When I tried to connect the device to Xcode to run and debug the app, the console showed me that message. So the solution was easy:

  • Stop the app in Xcode
  • Close the app in background

That's it.


you can put after calling the GANTracker a manual dispatch like that: [[GANTracker sharedTracker] dispatch]; and it work perfectly

0

精彩评论

暂无评论...
验证码 换一张
取 消