Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Google Universal Analytics for Unity - Support Thread

Discussion in 'Assets and Asset Store' started by tonic, Sep 25, 2013.

  1. mog-mog-mog

    mog-mog-mog

    Joined:
    Feb 12, 2014
    Posts:
    266
    Did you find any analytics plugin with native libraries? I am still roaming around for the same !!!!
     
  2. florent-morin

    florent-morin

    Joined:
    Dec 2, 2014
    Posts:
    12
    Hi,

    How can I implement IDFA for iOS?

    Thanks.
     
  3. username132323232

    username132323232

    Joined:
    Dec 9, 2014
    Posts:
    476
    I'm new to this asset, so please forgive the basic question. My game has only two scenes: the level selector and a scene used for all levels. I pass it a levelNumber and the screen is initialized accordingly. So, the standard "New Level" event is not very useful because it doesn't show the level number.

    I tried the most obvious solution and added
    Code (CSharp):
    1.  Analytics.gua.sendAppScreenHit("starting level " + levelNumber);
    into the main scene script Start() function. This provides the information I need, but I'm not sure if this is the right approach. I think GA treats "New Level" events differently, so my approach is not the best. How would you handle this situation? Thanks!
     
  4. fporta

    fporta

    Joined:
    Sep 21, 2015
    Posts:
    1
    Hi,
    When I read the Google Analytics terms of service it mentions (https://developers.google.com/analytics/devguides/collection/protocol/policy?hl=en):

    • You will give your end users proper notice about the implementations and features of Google Analytics you use (e.g. notice about what data you will collect via Google Analytics, and whether this data can be connected to other data you have about the end user). You will either get consent from your end users, or provide them with the opportunity to opt-out from the implementations and features you use.
    What is your guidance on this? Is this done once per installation? How do we disable the service if user does not consent? (I would read documentation, but cannot find any).
     
  5. Gerold_Meisinger

    Gerold_Meisinger

    Joined:
    Sep 8, 2015
    Posts:
    93
    Hi! I bought your extension yesterday and reading the manual I eventually stumbled upon the official Google Analytics extension. What is the difference and advantages of those two extensions? In one of your comments and in the instructions you mentioned that GUA uses only Csharp code and thus it's cross platform. Because of the missing platform specific SDK it misses features such install referrers on Android and demographics reporting. Google's official extension also provides a measurement protocol solution though.
     
    Last edited: Sep 23, 2015
  6. illustir

    illustir

    Joined:
    Dec 12, 2014
    Posts:
    24
    The official GA stuff in that github repository does not work (linker errors) and the entire thing looks pretty unmaintained. I just tried out the packages they have there.
     
  7. Gerold_Meisinger

    Gerold_Meisinger

    Joined:
    Sep 8, 2015
    Posts:
    93
    We are using it in production, so I can confirm it works on Android, Windows Universal and Blackberry (using Unity 4.6.8). We are not getting any linker errors. You are right that it looks unmaintained as the last commit phase was Nov 2014.
     
  8. illustir

    illustir

    Joined:
    Dec 12, 2014
    Posts:
    24
    I just got a reply from somebody over on the project so I'm going to give it another go.
     
  9. danjakes

    danjakes

    Joined:
    Jun 5, 2015
    Posts:
    8
    HI,
    I bought the Google Universal Analytics plugin from the Unity Asset Store and set it up exactly the way it is mentioned in the manual. I was hoping to get some realtime tracking of the app but the realtime monitoring on the Google Analytics dashboard always says 0 active users on app, no matter what I do. I tried the bundled examples as well as a fresh project in Unity but the results were the same. Non-realtime analytics worked fine. I was able to see yesterday's data today. It's just the real-time tracking that's not working.

    I'm using the plugin for a Windows/Mac/Linux desktop app.

    The steps that I did to set it up were:
    1. Created a new property on GA with mobile app tracking.
    2. Set the default view to 'All mobile app data' in the property settings
    3. Added the 'Analytics' script component to an empty game object in Unity and set the tracking ID to the one in the GA property setting.
    4. Set the app name in the component in Unity.
    5. Started the app in Unity.

    Appreciate it if someone could help me with this.

    Cheers
     
  10. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hello all, sorry for lagging with responses. Apparently the automatic forum notification had stopped working for me for some months! I'll try to provide some answers here in one big reply.

    florent.morin contacted me over email, but just for sake of completeness, I'll quote the relevant part here as well:
    @username132323232 :
    There are many ways to map the different types of hits with happens in app or game. I think best way is just to think yourself it separately for each app. Good way is to try out some possibilities by sending test data and then later (when it has been processed), check in the google analytics site if the end result makes sense to you or not. For some reasonably sized game with static set of levels I think it's fine to use screen hit like that, with the screen name being e.g.: "Level " + levelNumber.

    @fporta :
    I recommend you check out the included Analytics Example. When you test it, be sure to first add both "AnalyticExample" and "AnalyticsExampleSecondaryScene" to Scenes in Build (File > Build Settings...). When you start out, click the button "Go To Secondary Scene" - there's a simple opt-out checkbox. It's up to you to decide if that kind of simple approach is enough - it could be best if you make the selection even a bit more explicit (I guess also local laws may have different requirements for you regarding user tracking). And it should be separately for each app / installation. The purpose of that example scene and the small .cs scripts is to show you how to technically implement that (e.g. see Analytics.setPlayerPref_disableAnalyticsByUserOptOut method and how that and Analytics.gua.analyticsDisabled is used in AnalyticsExampleSecondaryScene.cs).

    @Gerold_Meisinger :
    Yes nowadays there's the official Unity extension as well, although it's still in Beta - and nowadays it also has a measurement protocol implementation which has diminished the need for my asset at least to some extent. I haven't done extensive comparison, but there are clear advantages for each other. Here's elaboration of some of the differences:
    In addition to what you already found out, my GUA asset has support for for Webplayer Plugin and HTML5 builds (back when I tested the official ga unity sdk, it just froze the whole webplayer - I don't know if it has been changed since). The pure Unity C# script approach is also very lightweight in comparison to the surprisingly large native code libraries on iOS&Android platforms, in addition to being inherently very cross platform friendly way. I've also hand-tweaked sending of hits so that it more reliably reports several platforms and versions in the Analytics site (there's probably no advantage on iOS&Android which have their own native libs in official ga unity lib, but for any platforms where their measurement protocol backend is used I think my asset is superior). Finally, there are some relatively minor tech differences in the way the API usage is constructed, I think their way results in a lot more temporary strings to be cleaned for the garbage collector (my GUA asset minimizes that by building internally using a single string builder and only converts to a string when necessary).

    @danjakes :
    It seems your setup is done right since you can see the events the next day. This isn't the first time the realtime has been a bit flaky (I have been asked about it before as well as it hasn't worked for a while). I just tried to setup a new property myself and test it and I can't either see realtime hits for a new property - however, the realtime hits still work for some older property I'm using (in combination with this GUA asset). After some web searching, it seems it's a common problem right now, as I also found some complaints over stackoverflow about it.
     
  11. danjakes

    danjakes

    Joined:
    Jun 5, 2015
    Posts:
    8
    @tonic:
    Thanks so much for the response. Is there any possible way something could be done about the realtime tracking?
     
  12. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @danjakes No idea. I just checked again with my new test property and it's just like you described: I can see the hits from past days, but nothing in the realtime view (overview). And the same application still reports hits to the realtime view just fine if I use an older property.

    It's worth noting one must be using a view which tracks "mobile app" and not a website, but by default you most probably already have just one view with the right type. I also guess you haven't set up any filters to filter out "internal traffic".

    After all this asset is just a wrapper for the Google's stuff, so almost everything like this is unfortunately beyond my control... I'm inclined to wait for a while (like a few weeks or even months) to see if it just gets fixed, before thinking about submitting a bug report which will probably take even longer to be processed and fixed.
     
  13. ted-gamaya

    ted-gamaya

    Joined:
    Apr 16, 2013
    Posts:
    6
    Hi tonic. We're looking for an Analytics solution and your plugin looks great! Wanted to ask you a couple of questions:

    1) Does your plugin use IDFA at all? Reason being Apple asks if the app uses IDFA at all so I want to know how to answer that when we submit our app to them.

    2) Does your plugin work on Amazon? Yes it's an android but they have their own submission process and want to make sure there's no problems in using your plugin. Do you know if others have successfully used your plugin for Amazon Apps?

    Thanks!
    Ted
     
  14. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    No it doesn't. There's no native code in GUA asset, and no Unity APIs are used which should trigger use of IDFA.
    (Note: there's no support for demographics reporting or install referrer tracking, which would probably require IDFA use on iOS...)

    Unfortunately I don't know for sure. My best guess is that it works, but I haven't personally verified this, and haven't heard anything about this from users (good or bad).
     
  15. robertwahler

    robertwahler

    Joined:
    Mar 6, 2013
    Posts:
    43
    Any chance of tvOS support?

    It looks like you can provide support as long as the cache system is modified to use PlayerPrefs and strictly limit the number of items stored in the cache. There is a 500kB local storage limit for the entire application.
     
  16. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi Robert, thanks for the suggestion & implementation idea. I do not have a tvOS device or immediate plans to buy one, and I'm fairly busy with other stuff... so while it looks like the modifications wouldn't be very big, I won't be adding support in the near future at least.

    My guess is that the asset would work without offline caching after a few mostly straightforward changes. If you want to try that yourself, look for any #if check about UNITY_WEBPLAYER or UNITY_WEBGL. If that particular code is about offline caching, add the tvOS to the #if-checklist.. but if the code is about sending the requests, then you need to keep that for tvOS (but still comment-out any remaining bits of offline-related code).
     
  17. robertwahler

    robertwahler

    Joined:
    Mar 6, 2013
    Posts:
    43
    Thanks for the tvOS change ideas. I tried that and the system runs without error but I'm not sure how the lack of a cache affects the system. I assumed the cache works like a queue, if you send too many events, like what happens at the first app startup, then you could lose events without the cache/queue. Is that not how it works? If so, then a small FIFO queue with a cap of 25-50 events would prevent event loss even when on-line the entire time.
     
  18. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @robertwahler The offline queue in GUA is primarily built for storing hits for a short while when device is offline. So it's not explicitly used for rate-limiting, i.e. there's no internal rate-limiting. However if GA returns with an error code (e.g. due to backend problems, in theory could be due to rate-limiting), then hits will go to the queue and will be retried later.

    The GA site has some info about the applying limits and quotas here:
    https://developers.google.com/analytics/devguides/collection/gajs/limits-quotas#universal_properties
    The GUA asset falls under that "Universal Analytics Enabled" section. It doesn't say that such hits need to be rate-limited, although at end of page different rate-limiting systems are described for each official client library (not applicable here). More important is to remember the hit limit for each session.

    Since the rate limiting is not explicitly required, and it will work in practice if the GA site returns an error code as described above, implementing rate limiting internally to GUA asset hasn't been a high priority for me although it is on the "potential features to do" -list.

    (But, you're right that if all offline queue support is removed, all hits will be lost if network is even just temporarily unavailable.)
     
  19. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    Hi,
    I'm updating an older Unity 4 project to Unity 4.7 for iOS on OSX El Cap.

    I updated to the latest GoogleUniversal package but getting 6 compile errors on Analytics.cs

    Like: UnityEngine.SystemInfo does not contain definition for "graphicsMultiThread" + 5 others

    Some of them are the same logerror messages reported in this post http://forum.unity3d.com/threads/google-universal-analytics.202335/page-3#post-2046747

    I've deleted the folder and reimported but errors still exist.

    logmessagereceived is a Unity5 addition so why isn't it getting ignored in Unity 4.7?
    • Application.RegisterLogCallback() and RegisterLogCallbackThreaded() have been deprecated and replaced by two new events Application.logMessageReceived and Application.logMessageReceivedThreaded. This allows for multiple subscribers.
    • https://unity3d.com/unity/whats-new/unity-5.0

    any clues?
     
    Last edited: Jan 12, 2016
  20. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi! I didn't realize I should've done an update when Unity 4.7 was released, as a few tiny changes are needed with the #if checks to properly detect Unity version.
    I'll email you a preliminary fix for the Analytics.cs right away.
     
  21. sozeray

    sozeray

    Joined:
    Aug 24, 2013
    Posts:
    2
    Hey @tonic,

    Thanks for this useful plug-in and the for the support you are providing. I'm also using the latest version of the plug-in with Unity 4.7.0 and getting the exact same errors with @sonicviz. Can you help me with this?

    Thanks!

    Edit: OK, nevermind. If anyone is getting the same errors, just edit the preprocessor directives in the Analytics.cs and make them include UNITY_4_7.
     
    Last edited: Jan 23, 2016
  22. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @sozeray, glad to hear you solved the problem already. The fix is indeed a very simple one like that, I just haven't gotten around to pushing an update to the asset store yet.
     
  23. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
  24. DevMacOleg

    DevMacOleg

    Joined:
    Apr 20, 2016
    Posts:
    2
    Hi! I use version 1.6.2 and have some problems with transaction hits on WP8 platform.
    I use sendTransactionHit and sendItemHit.
    There are no errors within the logs, but I don't see these events at Google Analytics Panel.
    I cheked all the settings at the Google Analytics Panel and Unity - everything is OK!
    Could you tell me, please, what is the problem?
     
  25. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @DevMacOleg,

    Do other hits work when sent from WP8 device? That is, are you having problem specifically only with the transaction hits?

    Also, have you tested if the transaction hits work when sending from another type of device (either mobile, or e.g. just testing from unity editor itself), i.e. is this only WP8 specific?

    While I tend to try to help with GA usage questions as well, I can't claim to be an expert on all actual GA things (and for example I haven't used the transaction stuff in a "real project" at all). This asset is after all merely a convenience wrapper to API specified by Google. But I'm of course interested to find out and fix if this helper/wrapper itself has any problem in passing proper requests (possibly on a specific platform), which is why I'm asking the above extra questions ...

    Other than that, I'm not exactly sure what's the actual status regarding the transaction hits. Some time ago Google introduced the "enhanced ecommerce" addition (which are also in the GUA asset API), and their dev.guide does state that one "should" use that instead of the transaction stuff. But I don't know if that means that the older api still works or not. You can read more about that from this web page: (section "Enhanced Ecommerce Tracking")
    https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide
    So it might be that one should use that API part instead. If you decide to try to migrate, please report back any findings...
     
  26. DevMacOleg

    DevMacOleg

    Joined:
    Apr 20, 2016
    Posts:
    2
    Yes, I have problems only with transaction hits this time.
    I try the transaction hits from wp8 devices, Unity Editor and Windows Desktop application.
    I think, that it is a WP8 specific problem. However, I didn't try them on IOS or Android. So I can't say if it works on these platforms.
     
  27. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Can you then see transaction hits in GA site which are submitted with Unity editor or Windows Desktop application?
     
  28. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    I was struggling with an issue with unity preprocessor and investigating deeply in the whole solution I found this in your files:

    Code (CSharp):
    1. #if UNITY_EDITOR
    2. #define DEBUG
    3. // it's good idea to keep DEBUG_WARNINGS enabled when running in editor!
    4. #define DEBUG_WARNINGS
    5. //#define DEBUG_LOGS
    6. #endif
    7.  
    Unfortunately I was also using the DEBUG preprocessor and then I started to have issues.
    Would not be better to use a prefix for your defines, something like:
    GUA_DEBUG, GUA_DEBUG_WARNINGS, GUA_DEBUG_LOGS

    Thanks
     
  29. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @mcmorry, that #define applies just locally in that file, which shouldn't be a problem at all.
    But, if you're having some kind of problems, I guess you mean that you're using some way to define a global project-wide "DEBUG" and that then happens to affect GUA as well?
     
  30. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Yes I'm defining a global scope DEBUG for some code that should be excluded when going for production. I can't use the Unity predefined symbols because I need to disable this code when profiling already in the editor.
    Probably nothing would happen to your code, but using very common names inside plugins could have unexpected result to the user, for example, in case of DEBUG symbol, emitting additional unwanted logs.
    So no, I'm not having any issue with your plugin, but I thought could be worthy to express my opinion.

    Anyway I filed a bug to Unity because even in empty project, a global DEBUG symbol is always defined.
    I'm on Unity 5.3.4f1, but in some previous version was not like this.
     
  31. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Yes, I see. Thanks for the suggestion! To use GUA_ prefix in my asset is indeed a good idea - hadn't thought about that before in connection to potential global defines...
     
    mcmorry likes this.
  32. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    514
    I was just wondering if you plan on wrapping your Analytics class in a namespace. I guess I'll do this myself, but I'm getting a clash with the native Unity analytics class (I use a few analytics services in the one project).
     
  33. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @jason_yak Hi, thanks for the heads up / reminder.

    Should definitely do that, added it to the todo list. So far I've pushed back things like that (like renaming or moving around classes), so that there wouldn't be any extra hassle when upgrading from old versions. But yeah, I guess getting a clash with Unity's own thing should be a reason enough to do this. :)

    It will take a while until I make an update again though, so please just do the namespace wrapping yourself for now.
     
  34. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    514
    Yup no worries, have done

    namespace Strobotnik {}
     
  35. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    514
    Btw.. another suggestion for a future update. I noticed that you'd started using SceneManager to grab the active scene name, but as of 5.4 OnLevelWasLoaded was deprecated and doesn't fire anymore. You need to use something like:

    Code (CSharp):
    1. SceneManager.sceneLoaded += OnSceneLoaded;
    2.  
    3.     void OnSceneLoaded(Scene scene, LoadSceneMode mode) {}
    I report screen hits in my implementation manually anyway, but just a heads up that it won't be automatically reporting screen hits (as far as I can tell) for people using 5.4 up.
     
  36. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    514
  37. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    514
    Sorry another one... I noticed earlier someone was said they were having trouble with the windows phone data submitting, I'm also needing to support windows 10 UWP. I'm wondering if it needs a user agent added to the initialize method of GoogleUniversalAnalytics like this, but note I'm not sure if this is entirely correct ie. it's unverified at this stage:

    Code (CSharp):
    1.  
    2. #if UNITY_WSA
    3.         string deviceModel = SystemInfo.deviceModel;
    4.         string operatingSystem = SystemInfo.operatingSystem;
    5.         sb.Append("Mozilla/5.0 (compatible; MSIE 10.0; ");
    6.         sb.Append(operatingSystem);
    7.         sb.Append("; Trident/6.0; IEMobile/10.0; ARM; Touch; " + model + " )");
    8.         string userAgent = sb.ToString();
    9.         sb.Length = 0;
    10.         customHeaders.Add("User-Agent", userAgent);
    11. #endif // windows 10 / UWP
    12.  
    Also note that I've only set this up for windows 10 UWP devices, for windows phone 8 you need different preprocessor directives. The windows ones seem to be all over the place, this class and other code in my project for that matter uses UNITY_WP8, but the unity docs have it as UNITY_WP_8:
    https://docs.unity3d.com/Manual/PlatformDependentCompilation.html
     
  38. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @jason_yak, sorry for a bit slow reply (seems I didn't get additional mail alerts of your later posts, after the first one on that day).

    1. Thanks for the heads-up about OnLevelWasLoaded.

    2. (tvOS) If a special user agent is not defined, it's likely that the hit will still be counted, but in Google Analytics it may show up as "unknown" (or something). Or depending on platform, possibly even miscategorized into some other. I don't have a tvOS device so for now I'm dependent on user feedback&suggestions for any changes about that. It depends on what might be used as default user-agent on the particular platform by Unity's own WWW class.

    3. (WSA) It has been a while when I last time tested through all these small details on a WP/WSA device, so I must admit I'm not entirely sure of the current user-agent situation there. On the surface your custom user-agent looks fine - but yes, of course ultimately what's detected by GA matters, so need to be actually verified.

    Also, about the WP8: I have tested GUA to be working on a WP8 device, but WP8 support has been now dropped by Unity itself. Also, earlier Unity version(s) (e.g. 5.1) used UNITY_WP8_1, but latest seem to use UNITY_WP_8_1. Should be easy fix to change that in case of compilation errors, but if you hit any, please report them.

    I'll try to re-test for any new findings about the user agent strings at some point, but as I tend to be quite busy, I of course appreciate any verified info/feedback about how to improve detection on new platform versions or platform variants. In any case, thanks for informing about these things.
     
  39. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    514
    It'll probably be quite a while before I get to test the windows and tvOS stuff as well, but when I do I'll get back to this thread.
     
  40. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    514
    Hey do you know does the offline cache streamwriter which uses the persistentdatapath, will that need the write permissions for android?

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    I'm wondering if I need to do a runtime permission request in Android 6.x.. if I did I guess it would need to happen when the app launches.
     
  41. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @jason_yak, I did some Googling to reclarify my assumptions, and it seems the persistentDataPath will point to internal storage if there's no permission to write to external storage. So the ext (sd card) writing permission is not required.

    But, I'm not actually sure about the Android 6.x. I wonder if Unity will do the request on your behalf when the external write access is set in the player settings. By some info I found, it's apparently possible that the persistent data path will first point to internal and then change to external if the external write permission has been asked for. So I guess you're right that the permission should be asked in advance to be safe, i.e. before initializing analytics (will actually be needed only when analytics hits can't be sent, i.e. when user is effectively offline).

    In my tests I've always set target to a lower android version, don't know if that has any difference regarding this.
     
  42. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    514
    It is a tricky topic hey. There's so much misinformation and confusion in forums and even google docs. I too saw the mentions that the persistentDataPath possibly switching once the write permission is granted, and that in some cases it was only after an app restart that the permission and write path was actually put in to effect. But I tried to replicate this and could not do it on a Samsung S5 running Android 6. These problems may only occur when compiling with or running older SDK versions.

    So interestingly I also tried to force some write errors under Android 6 to see how best to handle them and strangely discovered that it was all working despite definitely not having permission. I've discovered that since api 19 that some write ops to external storage don't even check this write permission at all, and soooo many people online are not aware of this and continue to check and request for this permission when they don't need to. If you are targeting lower than 19 then of course you'll still need permission in there but I've modified mine like this (I would have removed entirely but Unity keeps auto-adding it in):

    Code (CSharp):
    1. <uses-permission android:maxSdkVersion="18" android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    and as of Jan 2016 apparently the Play Store will read this and will not advertise that the app requires this permission if it's running a newer OS version, and if you are won't need to request this permission either at runtime on Android 6 or even at install time for apps on api 19 and up. There's still some unknowns, I don't know under the hood whether this covers all write methods that could be used by Unity, and I don't know all of the circumstances and differences in models that might trip all of this up. But so far this seems to be passing all test for me.

    Short story is I don't think I need this permission because I'm targeting api 19 and up.
     
  43. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    514
  44. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    That's very interesting, and indeed a bit confusing. Thanks for sharing your findings!
     
  45. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    514
    A little bit of a follow up. We've done a heap more testing and confirmed that devices running Android 5 down to API 19 are fine to use those write methods without needing the permission, and also confirmed that the Play Store does read that maxSdkVersion attribute. So when installing on and Android 5 phone we get a nice popup saying 'This app does not require any special permissions'. For Android 6 which doesn't have a permission request when installing and is meant to be managed at runtime we add this to the manifest:

    Code (CSharp):
    1. <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="true" />
    which tells Unity not to ask for permissions (on Android 6 or newer) when the app starts.

    So anyway, with all of this and as far as I know, no we don't need to request permission so the offline cache can write. =)
     
  46. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    That's great to know! So when using that SkipPermissionsDialog, and not requesting permission explicitly, does it mean any write to the Application persistentDataPath will go in the internal memory?
     
  47. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    514
    I've read that the behaviour of whether the persistent data path is using internal or external can change around a fair bit depending on models. Maybe it was Huawei devices that allow users to choose to default to external memory instead of internal. Then it might depends on what settings you have for write access whether it's using internal or external as well, at least it used to. But with my Samsung S5 I tried to change as many settings and conditions around to see if the paths would change, reseting the app in between attempts etc. but when logging the persistent path it was always the same for me which was a little odd. I had read that for some devs when the external write permission was granted that (in some cases after a restart of the app) that it would change the persistent path from internal to external. But in my case (from api 19 up) I think the write permissions simply have nothing to do with anything, I was never seeing the path change at all. It seems more like from my tests that it's just using external by default, and that the write permission is ignored as per the android docs. It's possibly even ignoring the write access settings in Unity?! So maybe in some cases it could be internal, but for reasons that have nothing to do with permissions as far as I can tell.
     
  48. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Okay, so it just needs to be tested on several devices to know for sure. :)
     
  49. phoenixrising

    phoenixrising

    Joined:
    Aug 9, 2013
    Posts:
    57
    I am just incorporating this into a new project and I was wondering if it possible to use this with firebase?
     
  50. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @phoenixrising, thanks for asking.

    I briefly looked at Firebase a while ago. My understanding is that the Firebase is a different product, one could maybe compare it to Unity itself (in a way). Firebase analytics just seemed to be a part of the Firebase itself and exclusive to it.

    But as it's a different thing, Google Analytics is still there and works just fine.

    Even if there will be some reasonable way to incorporate analytics of Firebase to external things, I'm fairly sure I won't be adding support for that in this GUA asset. Additionally it seems to be only iOS/Android/Web specific, so I'm not that interested in it, as GUA is meant to be more cross-platform than that.