I have an app where I am trying to track screens with Google analytics.
I have set everything up in the delegate, and tried to automatically track three screens. Out of the three screens, only 1 of them is automatically tracking, the other two I had to track manually. I do not understand why this is the case, but I've tried looking for solutions and answers but none have come up.
The one class where the automatic screen tracking worked in in my SettingsViewController
in SettingsViewController.h I import "GAITrackedViewController.h"
and in SettingsViewController.m I do the following:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.screenName = #"Settings";//GOOGLE ANALYTICS WAS IN ViewWillDisappear
//rest of code
}
This works because in Google Analytics, I can see all the times that I've seen this view and I have all the tracking data necessary.
It gets annoying in my other two classes where I tried the EXACT SAME THING and did no get the same results.
In both my FriendView and HomeView I tried doing the automatic screen tracking, but that did not work in either view, so I tried implementing the manual screen tracking.
In both my HomeView and FriendView I do the following:
#import "GAI.h"
#import "GAIFields.h"
#import "GAIDictionaryBuilder.h"
#import "GAITrackedViewController.h" //Import from when I tried automatic screen tracking
and then I do
-(void)viewDidAppear:(BOOL)animated{
//self.screenName = #"Friends";//GOOGLE ANALYTICS
[super viewWillAppear:animated];
id tracker = [[GAI sharedInstance] defaultTracker];
[tracker set:kGAIScreenName
value:#"Friends"];
[tracker send:[[GAIDictionaryBuilder createAppView] build]];
}
The manual tracking works better because I can see it under real time screen tracking. But for some reason I still cannot see FriendView or HomeView screen tracking under Behavior/ Screens in Google Analytics. The only data I have is from the SettingsView.
I would much rather use the automatic screen tracking because it is less code, but I have tried this solution and various others to try and get automatic screen tracking to work, and to be visible in Google analytics but it just does not.
To be clear, in both cases, the data does not show up in my screen tracking data. Only my settingsView data is visible and sending. The only difference is that when I do the manual screen tracking I can see the data come in real time, but it still does not show up in the general screen data view.
I am using v 3.0.7 in my app.
Thank you in advance for any solutions.
I also tried all different ways to track screen views in GA (manual vs auto, createAppView vs createScreenView, in viewDidAppear vs in viewWillAppear, etc) and for a long time I thought they weren't working. I also turned on verbose debug mode and everything seems correct (returning 200, screen name being logged as I expected). Later I realized that they were actually recorded, I was just looking at the wrong place in GA website.
They are not in Site Content/All Pages, and they are not in Behavior Flow, or Events/Pages. But if you select anything like an event, and select "Screen Name" as a primary or secondary dimension, then you can see all of them. Or you can create a customized report and directly display screen name.
I'm surprise that screen views are so hard to find in the GA web interface. I hope that Google can make a change to treat the screen views like web's pages, and be able to see a flow chart of the transitions.
EDIT:
Then I realized that it's because I'm posting all the data into a view that's configured for website, not for mobile app. (Initially we wanted to track app and web in the same view.) When I created a new GA view for mobile only, everything makes sense now.
Everything is perfectly fine only the section in which you are searching the screen is wrong. So go to > Reporting > Real Time > Screens to view you screen or else try to search SCREEN in the search box and that will give you various options then try them one by one to get the correct option.
To automatically measure views in your app, have your view controllers extend GAITrackedViewController. Set a property called screenName with the name of the screen that you want to appear in your reporting.
For example, suppose you have a “Home Screen” view that you want to measure with a view controller header that looks like this:
#interface HomeViewController : UIViewController
You would update this header to:
#import "GAITrackedViewController.h"
#interface HomeViewController : GAITrackedViewController
You must also provide the view name to be used in your Google Analytics reports. A good place to put this is the view controller's initializer method, if you have one, or the viewWillAppear: method:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.screenName = #"Home Screen";
}
For more information Please go through this link Google Analytics
the whole code is look like this
Related
Ok. Here is the question. I have tabBar controller, in tab at index 0 I have a TableView with cells showing video by AVPlayerViewController. For iPhone, when i print content of UIApplication.shared.windows - it has only 2 window - UIWindow and UITextEffectWindow. But for iPad - it has UIWindow, UITextEffectWindow and several PGHostedWindow (3-4 depends on the number of cells with video).
What are those PGHostedWindows? It seems to me that they are creating along with AVPlayer when it's view is added to cell's view hierarcy - and it led me to the thought that it may be connected with iPad's ability to show video in "Picture in picture" mode. But even if I set AVPlayerViewController's allowsPictureInPicture to false - those windows are still creating. And the worst part - even if I scroll those cells with video from visible area,or go to another tab - those PGHostedWindows are not deallocated.
So the question is - what are those PGHostedWindows/ and how to prevent their creating?
I was trying to debug an AVKit issue with restoring from picture in picture and also noticed and wondered about PGHostedWindow. Like another commenter said, I don't see a reason for concern about its creation or lifetime. My understanding is AVPlayer moves the AVPlayerLayer between windows when moving in/out of PiP, and this window is one that the system manages.
Of note, which led me here: I noticed there is a longstanding issue where any subviews on AVPlayerLayer get clipped by the video after the view gets reinstalled on PiP. Apple's sample code has the same issue if the controls are extended. So maybe there's a few issues with PGHostedWindow, but we're stuck with them.
I've got a TableViewController with static table; one of it's cells houses an UIView named graphArea. The view renders a chart, it's background and an axis line - all inside it's drawRect(). There are also two another views (sunView & markerView), that are made with Interface Builder and used for chart dynamics (moving marker line and point on touch events).
All worked buttery smooth until I've implemented and tried to test a share button, that employs the ordinary activityViewController mechanism.
The magic begins, when one from a couple of share activities, whose share plugin window takes the full screen, is finished (no matter whether sharing succeeded or cancelled). The app crashes.
Discovery using debugger made apparent to me, that the crash happens, because some views, including graphArea, sunView, markerView are nil after return from sharing screen.
Only some of fullscreen share plugins (like preinstalled Mail and Messages, or, in my case, "Download to DropBox" action) lead app to crash. Other fullscreen share plugins do not (tested Telegram, WhatsApp, Skype). No one of those non-fullscreen plugins has ever caused crash (Evernote, Twitter, 2Do etc.).
It looks like graphArea, sunView, markerView are deallocated from memory when "malicious" share plugins take full screen. I haven't figured out, why.
Here's some debug info:
The traceback and assembly of fatalErrorMessage.
The next screenshot shows a part of controller code and properties, that are nil on return from share plugin (gray selection). And yes, they were all non-nil before.
Please, help me! Thank you in advance!
Thank you, Palpatim. My friend also pointed me at the same thing: I've put graphArea.removeFromSuperview() in viewDidDisappear(), and this caused the exception after share plugins, that have .presentationStyle = fullScreen. So at the point, when the app is to show again, there is no more graphArea in on the tableView.
I have been working on an app that uses UIDynamics in UICollectionView. I have watched Apple WWDC video and have also tried this sample app in Github.
However, I had this weird problem: When my app launches, I set the number of items for my collection view to 0, the app needs to download something from the server then populate the collection view on the main thread. Weirdly, it's (kinda) reloaded, but not showing anything. I tried on the sample app from Github and it has the same issue as well.
However, if I remove this part:
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect{
return [self.dynamicAnimator itemsInRect:rect];
}
The CollectionView will show what I want but without the UIDynamics.
I hope the illustration on my problem is easy to understand. Any help will be much appreciated. My guess is I shouldn't use reloaddata.
So I'm creating and showing a custom window in my iOS app because I'm writing a dynamic alert view that also functions like a growl/toast alert. It works AWESOMELY in ios6 (Hopefully I can open source this baby and you can all check it out)
But anyway, when I run this in ios5, the window that my alerts exist on doesn't seem to rotate with the device/simulator. No matter what, my custom window stays in portrait mode.
The UIWindow is just a UIView subclass, so there's no nice 'shouldRotate' delegate method.
I'm kinda stumped on why this is happening in ios5 but not 6. Any help would be GREATLY appreciated ^_^
My window has a rootviewcontroller, which I completely forgot about. I just needed to implement
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return YES;
}
To get it to work.
:-D
It's usually not recommended two use multiple instances of UIWindow in one iOS app. The only valid reason to do so is to support external screens. You should use a UIView instead, ideally managed by a UIViewController.
I assume, (since you didn't provide any code, I can only assume) the reason why your window doesn't 'rotate' is, that it's simply not getting any notifications about device rotation. Only the keyWindow receives them by default.
I would highly recommend to redesign your app to use a properly managed UIView instead. If you desperately don't want that for some reason, you would have to register your instance of UIWindow to receive the UIDeviceOrientationDidChangeNotification and then (in the handler) evaluate what the new orientation is and change the window's frame accordingly (plus maybe other things that need to be done in response to the orientation change)
I've just started learning iOS development for iPhone, and following a couple of examples regarding how to display a mapView with the MapKit Framework, I found that google map tiles are not displayed, I only get an empty view (grey tiles), at least in the iPhone simulator (I haven't tried on a device).
I also get this error message:
/SourceCache/GoogleMobileMaps_Sim/GoogleMobileMaps-363.1.2/googlenav/mac/Loader.mm:235
server returned error: 403
I found solutions for similar problem when developing for Android, but not for iOS. Could somebody help me with this issue? Adding the MapKit framework to the project is supposed to be enough to get this working, or maybe am I missing some extra settings that are not mentioned in the tutorials I've followed?
Thanks!
This is the simple sample code I used:
// ViewController.h
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
#interface ViewController : UIViewController
#property (strong, nonatomic) IBOutlet MKMapView *mapView;
#end
// ViewController.m
#import "ViewController.h"
#implementation ViewController
#synthesize mapView=_mapView;
- (void)viewDidUnload {
[super viewDidUnload];
[self setMapView:nil];
}
... more methods...
And in .xib file, I connected a MKMapView to the file's owner mapView outlet. And at this point, according to the tutorial, I am supposed to be able to see a default US map when running the simulator, but I'm always getting the error I posted before at the debug area, and map view displays only the grey empty grid.
I had the same problem - my UIMapView was only showing the grid, but not the actual map. I quit the simulator and then launched the project again - now it showed the map! It seems like iOS simulator does loses the connection sometimes, even though you might be connected on your computer.
Thank you all for your input!
Have you set the delegate to files owner(self)?
Also have you included mapkit framework and the related header files?
For whatever reason, my iOS simulator sometimes just loses connection to the internet (my computer has connection, but the simulator doesn't recognize it). Once I quit and relaunched my simulator, my maps started showing.
The iOS simulator comes with the official maps app included. Open that and verify that it can get tiles, it could be a network issue. Without any code, outlets, delegates or anything the map should show map data.
An empty map view (grey tiles) as you've described I have seen on the iPhone simulator and a device when trying to specify a map region (see code below for example), however the user has not granted access to their location in app settings. Removing this piece of code when running on the simulator resolved the issue.
MKCoordinateRegion mapRegion;
mapRegion.center = self.mapView.userLocation.coordinate;
mapRegion.span.latitudeDelta = 0.02;
mapRegion.span.longitudeDelta = 0.02;
[self.mapView setRegion:mapRegion animated: YES];
In case anyone looking for the solution. Network issue is solely responsible for this issue. Make sure your simulator has network connection and if it is able to load default apple map, you're good to go.
This issue is a little bit tricky because it involves lots of cases, but for me, it was not loading because of the network monitoring application, eg. Charles, make sure that you have an internet connection and it's unmonitored
I solved this problem by connecting to WIFI with my phone. I didn't have a SIM card installed in my phone, so it just showed the tiles. Just make sure you have network connection.