Search Unity

[Released] Android Native Plugin

Discussion in 'Assets and Asset Store' started by stanislav-osipov, Sep 20, 2013.

  1. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    Hello,
    I understand what you are talking about. Thank you for such a detailed information.
    It's not an easy topic to talk about in a forum circumstances.

    My recommendation for you is to contact our support engineer with all the information you mentioned here.
    Of course, I am required to give you the link to official access Google APIs with OAuth 2.0 documentation.
    Most likely, you have already seen this documentation. But anyway, please, check it. Most likely it will be helpful for you.

    Please, contact our support team and consider about the functionality you are going to implement in your application.
    Hope, you will get great help in such a way. Thank you for your patience and understanding!
     
  2. andrew210

    andrew210

    Joined:
    Apr 23, 2014
    Posts:
    241
    I'm having an issue with local notifications not clearing properly on Android only (am using Ultimate Mobile rather than just Android Native, but it only effects Android).

    Whenever the app is loaded or gains focus, this code is called:

    Code (CSharp):
    1.  
    2.             UM_NotificationController.Instance.CancelAllLocalNotifications ();
    3. }

    And whenever the app loses focus, it creates a notification for the following day reminding them to login at a certain time to avoid their "daily prize wheel" progress from restarting.

    However it appears that it doesn't cancel any notifications. In fact it isn't able to keep track of any notifications it's created. I have added this code to output for the user all of the notifications that have been created by the plugin:

    Code (CSharp):
    1.                     string data = string.Empty;
    2.                     if(PlayerPrefs.HasKey(PP_KEY)) {
    3.                         data = PlayerPrefs.GetString(PP_KEY);
    4.                     }
    5.                     List<LocalNotificationTemplate>  tpls = new List<LocalNotificationTemplate>();
    6.  
    7.                     if(data != string.Empty) {
    8.                         string[] notifications = data.Split(DATA_SPLITTER [0]);
    9.                         foreach(string n in notifications) {
    10.  
    11.                             String templateData = System.Text.Encoding.UTF8.GetString(System.Convert.FromBase64String(n) );
    12.  
    13.                             try {
    14.                                 LocalNotificationTemplate notification = new LocalNotificationTemplate(templateData);
    15.  
    16.                                 if(!notification.IsFired) {
    17.                                     tpls.Add(notification);
    18.                                 }
    19.                             } catch(Exception e) {
    20.                                 Debug.Log("AndroidNative. AndroidNotificationManager loading notification data failed: " + e.Message);
    21.                             }
    22.  
    23.                         }
    24.                     }
    25.                     for(int i = 0;i<tpls.Count;i++) {
    26.                         ChatMain.REF.HandleChatMessageReceived(null,tpls[i].title+"|"+tpls[i].message+" - "+tpls[i].fireDate);
    27.                     }

    This returns at most 1 notification for the user, but the users are reporting that they receive 1 notification for every time the app loses focus. Would I be able to get any help in sorting this out?
     
  3. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    Hello,
    It's quite hard to find out the reason of this behaviour in your project. Most likely, some additional information will be required from your side.

    Please, contact our support team with this information and this issue will be registered in our bug-tracker.
    Thank you for this report!
     
  4. Design3DGame

    Design3DGame

    Joined:
    Nov 24, 2016
    Posts:
    19
    Hi,

    The study of our game users experience showed that there are some collisions during saving of game data to Google Play Saved Games service when using methods from Android Native Plugin.

    We tryied to find out the reason of such behaviour and discovered that problem with game data save collisions is bound to next conditions.

    In most cases game data saving and loading operations work fine.

    But we found that when network connection is lost DURING save operation, than ActionGameSaveResult() method is frozen and user can't do anything since saving operation is not completed.

    When network connection is reestablished ActionGameSaveResult() method is not unfrozen automatically.

    When user makes second attemp to save game data than 2 instances of ActionGameSaveResult() method are invoked, and they return their results when save operation is finished at last.

    It means that frozen method ActionGameSaveResult() is unfrozen only when network connection is reestablished and second attemp of game save operation is started.

    We need to warn user if ActionGameSaveResult() method has been frozen when timeout would be reached.

    You can reproduce this behaviour using scene SavedGamesExample.unity from your example scenes.

    You need to enter debug mode and put breakpont inside Enumerator-method MakeScreenshotAndSaveGameData() before calling
    GooglePlaySavedGamesManager.Instance.CreateNewSnapshot() method.

    After running SavedGamesExample on your Android device, attach your debugger to app and start "Save" method.

    When breakpoint is reached, turn off network connection on your device and continue.

    Thus, you can see that ActionGameSaveResult() is frozen.

    We need to find a way to warn user that save operation is frozen due to lost of internet connection during save operation.

    Now we can't do that because execution flow is waitng for ActionGameSaveResult() method return result to continue.

    How we can arrange save operation execution flow to handle this collision?

    We need to wait 10 seconds and then output appropriate warning to user.

    But we must be sure that this warning is invoked due to frozen ActionGameSaveResult() method.

    How can we do that?


    Thanks and Regards,
     
    Last edited: Apr 21, 2017
  5. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    Hello,
    May I ask you to contact our support team with this case. Please, go for it and we will try to reproduce and fix this issue with your help. Provide as much detailed information according to this case, as you can.
    The reproduction route you described in your message is quite detailed.
    General tests will be performed on our side. The fix will be provided if any kind of issues will be detected.

    Thank you for your patience and understanding!
     
  6. Fremium

    Fremium

    Joined:
    May 2, 2017
    Posts:
    19
    I tried to build Android Native Plugin project in Unity using IL2CPP, but error was raised during build process.
    Please, tell me how to get rid of this error.

    Failed running D:/Android/android-ndk32-r10b-windows-x86/android-ndk-r10b/toolchains/llvm-3.3/prebuilt/windows/bin/clang++ -o "Temp/StagingArea\assets\bin\Data\Native\armeabi-v7a\libil2cpp.so" -Wl,-soname,libil2cpp.so --sysroot
    ....
    Temp/StagingArea\Il2Cpp\il2cppOutput/Bulk_Assembly-CSharp-firstpass_3.cpp:16814: error: undefined reference to '_MNP_ShowRateUsPopUp'
    Temp/StagingArea\Il2Cpp\il2cppOutput/Bulk_Assembly-CSharp-firstpass_3.cpp:16866: error: undefined reference to '_MNP_ShowDialog'
    Temp/StagingArea\Il2Cpp\il2cppOutput/Bulk_Assembly-CSharp-firstpass_3.cpp:16910: error: undefined reference to '_MNP_ShowMessage'
    Temp/StagingArea\Il2Cpp\il2cppOutput/Bulk_Assembly-CSharp-firstpass_3.cpp:16930: error: undefined reference to '_MNP_DismissCurrentAlert'
    Temp/StagingArea\Il2Cpp\il2cppOutput/Bulk_Assembly-CSharp-firstpass_3.cpp:16958: error: undefined reference to '_MNP_RedirectToAppStoreRatingPage'
    Temp/StagingArea\Il2Cpp\il2cppOutput/Bulk_Assembly-CSharp-firstpass_3.cpp:16978: error: undefined reference to '_MNP_ShowPreloader'
    Temp/StagingArea\Il2Cpp\il2cppOutput/Bulk_Assembly-CSharp-firstpass_3.cpp:16998: error: undefined reference to '_MNP_HidePreloader'
    clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)​
     
  7. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    This error indicates that there is an extern static method in C# code named "_MNP_ShowRateUsPopUp". That method should exist in a native library that is built for Android. It looks like that native library does not exist, so the linker step in the Android build fails.

    If that native library does not exist or is not used on Android, you should wrap the definition of _MNP_ShowRateUsPopUp (and the other functions that show up here) in a #if in the C# code, so that they are not compiled for Android.
     
  8. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    I don't think you have these compilation errors with the Android Native plugin.
    Most likely you have some other plugin included in your project.

    Taking into account the method names you mentioned (_MNP_ShowRateUsPopUp, _MNP_ShowDialog, _MNP_ShowMessage etc), I can assume that you have Mobile Native Popups plugin imported into your project, don't you?
     
  9. Fremium

    Fremium

    Joined:
    May 2, 2017
    Posts:
    19
    Yes. Mobile Native Popups plugin is imported into my project since I need Android native alerts. It seems that this plugin is also made by Stan's Assets Team. Removing Mobile Native Popups plugin from project solved the issue. Thanks.
     
  10. vivalavida

    vivalavida

    Joined:
    Feb 26, 2014
    Posts:
    85
    hi @AlexRay ,
    We wish that the user load their own audio files and possibly midi files(from the device) into the game, could you please point me in the right direction as to how to go about this?
    Mostly looking at opening the file browser and let the user select the file.
    I've looked at your 'Camera And Gallery' example but they seem to be designed only for images.
     
  11. Fremium

    Fremium

    Joined:
    May 2, 2017
    Posts:
    19
    I faced 2 problems when working with Google Play Saved Games feature.
    I am unable to save game data in some cases.
    My test case is a simple app having 4 buttons (Connect, Save, Load, RateUs).
    Connect, Save, Load buttons are used for connecting, saving and loading game data to Google Play Saved Games Service.
    RateUs button is used to call Google Play Store app with my app's game page.
    After rating of my app and selecting Return button on Android device, OnApplicationPause() event is raised in my app with if (!pauseStatus) check and SaveGame() method is called if !pauseStatus == true.
    After successfull connection to Google Play using Connect button, I select remaining 3 buttons (Save, Load, RateUs) in specified order.
    I repeat buttons selection sequence in given order several times.
    And suddenly after selecting of RateUs button and returning from Google Play Store my test app freezes and doesn't respond.
    StartCoroutine(MakeScreenshotAndSaveGameData()) is called, but ActionGameSaveResult() event is never reached.
    The error is floating.
    Sometimes to reproduce this error you need to call specified buttons selection sequence over 10 times.
    Another issue is that call of SaveGame() method from OnApplicationPause() event causes app freezing when call of RateUs button is repeated several times.
    I found that when calling SaveGame() method after some delay from OnApplicationPause() event than this problem disappears.
    But I am not sure that this treatment will work on other devices since when time delay is too short than this treatment doesn't work on my device.
    Another devices can have different response time periods and this error can arise again on different Android devices.
    Thus, I need to find how to solve these 2 issues:
    1. when app freezes after call of sequence of 3 buttons (Save, Load, RateUs) several times,
    2. when app freezes after call of RateUs button if time delay treatment is not used.
    What have to be done to handle these issues and avoid app freezing?
    See my C# script used during this test.
    https://github.com/Fremium/AndroidN...avedGames/blob/master/GooglePlaySavedGames.cs
    Please, help.
     
    Last edited: May 5, 2017
  12. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    H
    Hello,
    Unfortunately, we don't have such a feature for selecting mp3/wav/midi files from the device gallery into Unity side.
    Of course, the camera and gallery APIs are available only for photos.

    My recommendation for you is to contact our support team and request the new feature you described.
    Probably, the new feature will be added in following updates.
     
  13. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    Hello,
    I have inspected the code you provided. The code looks correct, but I am not sure, that you are familiar with Google Play Services flow of your application.
    When the Unity application goes to background, the player will be disconnected from the Google Play Services. And when the application become active, the Google Play Services connection will be called. It's general Google Play Services guideline and is called the reconnection. So, the situation is following. Probably you are trying to create a new game snapshot before you have the Google Play Services connection.
    Most likely you have to check the state of Google Play Services connection at first. And if you have not Google Play Services connection (most likely), you have to subscribe for player connectec event and make the new game snapshot there. This may be the solution in this case.

    The information you provided is not enough to clarifying this case for 100%. To be sure about this case, you have to inspect the LogCat logs from your Android device. Hope, you understand, that it's quite difficult in a forum circumstances. It takes time, you know. So, I would recommend you to contact our support team and ask for a support in this case. You will get great support in a short time.
     
    Last edited: May 5, 2017
  14. Fremium

    Fremium

    Joined:
    May 2, 2017
    Posts:
    19
    It seems that this issue is really raised by reconnection to Google Play Services. When I increased wait time period to 5 seconds, RateUs() method call works without any problems. But in Update() method (during wait time period scanning) GooglePlayConnection.State == GPConnectionState.STATE_CONNECTED inspite of that fact that reconnection is being made. Additional GPConnectionState.STATE_RECONNECTING is really needed to make it possible to catch when reconnection is finished.
     
  15. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    At first, you have to check Google Play Services state at first. If the state is not connected, you have to subscribe to ActionPlayerConnected event. This event will be fired, when the connection finished, and you will be ready to go with the creating snapshot coroutine.
     
  16. pl_ayground

    pl_ayground

    Joined:
    Dec 17, 2015
    Posts:
    60
    Hi,

    how do you handle the permissions dialog that is obligatory for Android 6.0 and above for Gallery Access? Is the dialog presented upon first app start or when I first try to access Photos? Also - do I receive user devision in code and can address it appropriately? I tried checking with the demo app but for some reason there were no dialogs visible there.

    Is there a way to avoid them like you did in Demo app? Thanks for clarification.
     
  17. Fremium

    Fremium

    Joined:
    May 2, 2017
    Posts:
    19
    I am trying to send gift request after successfull connection to Google Play Games Services.
    When I call gift request from simple test scene than everything is working fine.
    But when I call gift request from my game's main menu than FIRST call of SendGiftRequest() method results exception:
    AndroidJavaException: java.lang.IllegalStateException: GoogleApiClient must be connected.
    SECOND call of SendGiftRequest() method results successfull opening of Send Gift Dialog activity.
    I believe that this is connected with highly loaded UI of my game's main menu scene with a lots of buttons animations and background slideshows.
    My assamption is based on answer:
    https://teamtreehouse.com/community...ng-too-much-work-on-its-main-threadblogreader
    I can't affect on efficiency of UI used in my main menu scene since I am using third-party asset for these needs.
    I see from the LogCat output that GoogleApiClient is connected WITH SOME TIME LAG after SendGiftRequest() method call thought Google Play Services are already connected.
    And that is the reason of the issue since in simple test scene GoogleApiClient is connected JUST after SendGiftRequest() method call.
    SendGiftRequest() method call is fired in OnGooglePlusInviteActionComplete(AndroidDialogResult result) event raised in native Android dialog similar to OnRateUsActionComplete(AndroidDialogResult result) from code in previous question.
    Please, advice me how call GoogleApiClient connection method manually and how to subcribe to OnGoogleApiClientConnect() event (or similar) to move my SendGiftRequest() method call to this OnGoogleApiClientConnect() event implementation.
    Here is LogCat output for this case.
    https://github.com/Fremium/AndroidN...edGames/blob/master/LogCatSendGiftRequest.log
     
    Last edited: May 7, 2017
  18. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    Hello,
    The version of our Android Native Preview app on Google Play is quite an old version.
    I believe, this version doesn't include the runtime permissions features demonstration.
    Please, check our documentation about Runtime Permissions implementation guidelines.
    Hope, you will find the answers to your questions.
     
  19. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    Hello,
    I believe, that you have the wrong implementation of send gift request API.
    From the LogCat log, you provided I can see, that you make a send gift request before the Google Play Services connection ends up. You have GoogleApiClient must be connected error before the Play Serice Connection State -> STATE_CONNECTED message in the log.
    So, most likely, your implementation has some kind of issues. Please, pay your attention to it and try to fix it.
     
  20. Fremium

    Fremium

    Joined:
    May 2, 2017
    Posts:
    19
    1.Send gift request API implementation in my game project is similar to send gift request API implementation in test project where it is operating fine. I suppose that this issue in my game project is connected in someway with reconnection problem discussed above. I am calling Send gift request in method subcribed on event AndroidMessage.ActionComplete(). I wonder if AndroidMessage.Create() method call is treated as switching to different app? Thus, my app goes to backround with Google Play Services beeing disconnected. Is it true? And I need to check if connection is restored before calling Send gift request?

    2. During intergration to my game of Twitter share message feature I faced an issue connected with need of manual input of credentials in browser during authentication. I have Twitter app being installed on my Android device. It is very inconvinient to ask users to input their credentials manually when Twitter app is installed. Facebook authentication treatment in your plugin doesn't need manual input of credentials from users. Is there any way to extract credentials for Twitter in the same manner?

    3. I see that next time when Twiiter share message method is started, there is no promt to input credentials again. So, these credentials are saved. But sometimes credential save is reseted, and I need to input credentials again. What are the reasons of such behaviour? I use Chrome mobile for authentication to Twitter.
    Thanks.
     
  21. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    Thank you for clarifying this case! Yes, most likely you have to check your implementation.
    If you had the same behaviour earlier, please, try to make the same approach.
    Add the logic for checking the Google Play Services connection state. I believe, it will fix the problem.

    As I correctly understand, you want to use Twitter OAuth API in your app. In this case, you have to authenticate the user in your app. The user will be authenticated with the login process through the browser.
    There is another Twitter sharing approach. It's called native sharing. Please, take a look at the documentation I provided for you. Pay your attention, this approach requires the existence of the Twitter application on the users' device.

    First of all, the user login credentials will be reset when you clear the application data. Maybe you cleared the data during your tests and that's why you was prompted to log in again.
    Second, maybe some of the Twitter auth tokens were expired and login failed. The user will be prompted to provide login/password as well in this case.
    I can not say exactly what behaviour took place. The LogCat logs have to be inspected to be 100% sure about it.
    Hope, my answer will help you with this case.
     
  22. Fremium

    Fremium

    Joined:
    May 2, 2017
    Posts:
    19
    1. It seems that Twitter OAuth approach with login process through the browser saves authentification Twitter tokens in browser Cookies or similar since clearing of my game's application data doesn't affect on need in credentials input if they are already saved previously. Twitter native sharing approach is not suitable for my needs since it doesn't give possibility to tweet messages. In my game I check if Twitter app is installed since there is no sence to ask user in tweeting messages when he or she doesn't use Twitter app. Is there any way to use tokens from native sharing approach for Twitter authentification instead of login process through the browser to avoid need in manual input of Twitter credentials and tweet messages using stanard approach? Indeed, skipping manual input of Twitter credentials is very needed.

    2. In my game I want to avoid problems connected with Runtime Permissions issues for versions of Android API 23+. Thus, I've changed targetSdkVersion="22" in AndroidManifest file. But now I can't build my game project successfully since Unity build error is raised during attemp of merging of AndroidManifests. See Unity error log. Please, help me to find out how can I avoid these errors during AndroidManifests merge process since these errors are raised due to Google Play Services libs supplied with your plugin (and Facebook plugin). Is there any way forcibly change used targetSdkVersion for these libs without downgrading them? This is also very needed.

    https://github.com/Fremium/AndroidN...orDuringAttempOfMergingOfAndroidManifests.log
    Thanks.
     
  23. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993

    Twitter login process with entering the credentials in a browser is general approach. That's not our custom implementation.
    The Twitter OAuth approach differs from Facebook OAuth. With the Facebook, you will have native Facebook app activities displayed from inside your game. The flow looks more naturally. But Twitter forward user to a browser to enter username/password. Of courser, you can check the official Twitter documentation to make sure, that this is official Twitter user authentication flow.

    What kind of problems with runtime permissions for Android API 23+ do you have?
    Please, could you provide me detailed information according to this case? And I'll be able to help you.
    Unfortunately, I don't think you will be able to build your project with target sdk version equal to 22.
    There are few plugins in your project which require API version higher than 22.
    Facebook Android SDK, Facebook Android Wrapper and Stan's Assets Android Native plugin as well.
     
  24. Fremium

    Fremium

    Joined:
    May 2, 2017
    Posts:
    19
    Here are runtime permissions needed in my game that are not listed in so called normal permissions:
    1. android.permission.USE_CREDENTIALS
    2. android.permission.WRITE_EXTERNAL_STORAGE
    3. com.android.vending.BILLING
    4. com.google.android.c2dm.permission.RECEIVE
    5. android.permission.GET_TASKS
    6. com.android.vending.CHECK_LICENSE
    7. permission.C2D_MESSAGE
    8. android.permission.BIND_ACCESSIBILITY_SERVICE
    I plan to check ALL of them at each start of the game since it is hard for me to find out in code where I should put exactly every single runtime permission check.
    So, I would call PermissionsManager.Instance.RequestPermissions() with list of items enumerated in enum AN_Permission at each start of the game and I would check in event
    HandleActionPermissionsRequestCompleted() if all of them are granted.
    I have some difficulties since I can't find some needed runtime permissions in enum AN_Permission.
    I suppose that some modifications should be made in file AN_Permission.cs.
    Can you tell me how it should look like for my case?
    Are there any other modifications that are needed in different scripts of Android Native Plugin to operate with runtime permissions for my case?
    Thanks.
     
  25. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    There are some permissions which you will not be able to request at runtime. They have to be declared in your main application manifest. I am talking about com.android.vending.BILLING, permission.C2D_MESSAGE etc.
    android.permission.GET_TASKS is deprecated and I don't recommend you to use it in your project.

    Anyway, you can add any permissions you want to AN_Permission enum. You will be able to get the information about these permissions at runtime or try to request any of them. Please, go for it on your own.
     
  26. Fremium

    Fremium

    Joined:
    May 2, 2017
    Posts:
    19
    Let me clarify one moment. I've listed those permissions from my AndroidManifest file that are not listed in in Android Native Plugin's Runtime Permissions implementation guidelines as normal permissions.
    https://unionassets.com/android-native-plugin/runtime-permissions-511
    In your previous message you've told that com.android.vending.BILLING, permission.C2D_MESSAGE etc. are those permissions that I am not to be able to request at runtime.
    Is list of normal permissions in Android Native Plugin's Runtime Permissions implementation guidelines not complete?
    Please, specify what permissions from my list have to be requested at runtime?
    Thanks.
     
    Last edited: May 10, 2017
  27. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    The permission set of Android Native includes the permissions available on Android API 25.
    If you are looking for some older API-version permission, please, add it to your manifest manually or add any permission you want to AN_Permission enum class. But, please, be careful when you request these permissions on different Android platforms. That's the main point.

    You will answer this question better than me. I mean, this question is related to particular case (particular project).
    What permissions add to the main manifest before a build, and what request at runtime is up to you as a developer.
    If you want to reduce the initial set of requested permissions, then you have to ask for some of them at runtime.
    Hope, this information will help you.
     
  28. Fremium

    Fremium

    Joined:
    May 2, 2017
    Posts:
    19
    As I've realized from your comments, I should follow such treatment.
    AndroidManifest file has to contain all permissions, since my game initially supports Android API 15+ (minSdkVersion="15") and targetSdkVersion="25" (due to libraries' versions in the project).
    In my game I should check if user's Android device API level is greater or equal to 23 (Android 6.0 Marshmallow).
    If so, I should add at the start of my game permissions request method for those permissions that are considered to be dangerous on Marshmallow.
    As you've mentioned, Android Native Plugin's guides contain set of Runtime permissions for Android API 25.
    But where can I find list of permissions for Android API 23?
    I suppose that they can differ.
    Thus, do I need to make separate if-check for API 23, 24, 25 Runtime permissions?
    Please, help me to understand that.
    Thanks.
     
  29. venusboysatish

    venusboysatish

    Joined:
    Jul 10, 2012
    Posts:
    28
    we go the same issue. instead of calling cancel all notifications function, do this

    void RemoveAllLocalNotification()
    {
    if (AndroidNotificationManager.HasInstance)
    {
    List<LocalNotificationTemplate> scheduled = AndroidNotificationManager.Instance.LoadPendingNotifications();
    int[] allLocalNotificationId = new int[scheduled.Count];
    for (int i = 0; i < scheduled.Count; i++)
    {
    allLocalNotificationId = scheduled.id;
    }
    for (int j = 0; j < allLocalNotificationId.Length; j++)
    {
    AndroidNotificationManager.Instance.CancelLocalNotification(allLocalNotificationId[j]);
    }
    }
    }

    this worked for us.

    this is a major slip up from stan. bcoz of this bug, our game was showing 20-25 notifications in a single go. luckily our game is still in closed beta


     
    andrew210 likes this.
  30. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    I would recommend you to add as many permissions as you can to the main Android Manifest.
    The best approach is to request some particular permissions not related to the main functionality of your application.

    Let's assume, that your app is the game. And there is a possibility to save the screenshots to the gallery.
    So, in general, the user is not prompted to accept WRITE_EXTERNAL_STORAGE permission (this permission is not included in the main AndroidManifesl.xml file). And the user may never need this save to gallery feature of your game.
    But you have to request this permission at runtime. That's the best scenario for requesting permission at runtime.
    Hope, this information will help you.
     
  31. Fremium

    Fremium

    Joined:
    May 2, 2017
    Posts:
    19
    1. During Facebook feature integration using Facebook API with post sharing using WebView dialog I've faced issue when my message is SUCCESSFULLY posted to user timeline, but FB_PostResult of OnPostCompleteAction() event returns result.IsSucceeded == false (result.Error = "").

    Logcat outputs:

    V/com.facebook.unity.FB(20645): sending to Unity OnShareLinkComplete({"posted":true,"callback_id":"6"})
    I/Unity(20645): No Post Id: The given key was not present in the dictionary.

    It's strange, but several days ago it was working fine. I didn't make any modifications to this part of code. And finally I've found that Exception is raised in FB_PostResult.cs.

    After changing of
    _PostId = System.Convert.ToString(data["id"]);
    to
    _PostId = System.Convert.ToString(data["callback_id"]);
    the error is gone.

    I am not sure what is the reason of such behaviour, but it seems that Facebook team changed JSON data field name "id" to "callback_id" during last few days without any warning breaking backward compatibility.
    And finally, if select to CANCEL Facebook post sharing, FB_PostResult returns isSucceeded == true although RawData returns {"cancelled":true,"callback_id":"2"}

    Please, chect it out and give some recommendations how to avoid this issue and to take into acount that Facebook share post result can be cancelled, posted, failed etc.
    What modifications should be made to FB_Result.cs, FB_PostResult.cs to avoid this issue?
    2. I can't find these permissions in normal permissions list in Android Native Plugin guide.
    Does it mean that they have to be requested at runtime?

    3. I wonder if I'll include ALL permissions in AndroidMaifest file (normal and runtime permissions), and I would check if runtime permissions are granted and require them for Android API 23+ level at the start of the game, will it be alright?

    Can it cause any collisions? I mean that I don't want to make complex logic.
    Is this treatment appropriate?
     
    Last edited: May 15, 2017
  32. Fremium

    Fremium

    Joined:
    May 2, 2017
    Posts:
    19
    I am using GooglePlayConnection.ActionConnectionResultReceived event to check if Google Play Services were reconnected after AndroidSocialGate.StartShareIntent() method has been called for particular app.

    I can't use AndroidSocialGate.OnShareIntentCallback for these purposes since it is invoked before Google Play Services were being reconnected.

    But I've found that SOMETIMES Google Play Services did not invoke reconnection (did not invoke ActionConnectionResultReceived event) when I return from selected app to my game after making some social actions in the called app from StartShareIntent() method.

    I need to press home button to make my game to go to backround and then to put my game to foreground again manually by selecting it from the list of running apps on my Android device.

    Thus, GooglePlayConnection.ActionConnectionResultReceived event is finally started and I can reward user and save current state of my game settings to the Google Saved Games.

    But such behaviour is not appropriate. Similar problem can be reproduced when sharing post using Facebook WebView approach. The issue is invoked only sometimes (not everytime).

    It seems that in some conditions Google Play Services "forget" to reconnect after returning from background.

    Can you tell me how can I avoid this artifact?

    Thanks.
     
  33. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    We had few same reports during the last couple of days. This issue is related to some minor changes in Facebook SDK itself. As you correctly understand, this issue is not related to our plugin. We made a fix in our code, this fix will be provided with the following official update.
    The fix is super-simple. And you made it on your own. So, leave you code as it is.
    Anyway, the fix will be provided from our side with the upcoming update.

    You can't find these permissions because they are specific permission.
    You have to declare each one of these permissions in your AndroidManifest.xml file before application build.

    According to including the permissions in the main AndroidManifest.xml file I answered in the previous message - it's up to you what permission to include and what permission to request at runtime.
    I think you need some basic information about runtime permissions. Please, check official runtime permissions documentation and guidelines by Google. This information will be helpful for you.
     
  34. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    To be honest, the logic you are going to implement in your application is hard to understand.
    Did you check the status of Google Play Services connection, when you resuming the app after social sharing?
    I am talking about the moment when you don't receive the connection result received callback.
    Most likely the state was CONNECTED, that's why you didn't receive this callback.

    Please, double check it on your own. Hard for me to give you any other advice because I don't understand the logic of your app for 100%. Hope this my tiny advice will help you.
     
  35. Fremium

    Fremium

    Joined:
    May 2, 2017
    Posts:
    19
    It seems that I got your point from last messages.
    I'll try to make modifications in FB_PostResult.cs and FB_Result.cs code on my own.
    Can you tell me "cancelled" and "posted" are the only 2 options in JSON-answer that are possible?
    {"cancelled":true,"callback_id":"2"}
    {"posted":true,"callback_id":"1"}
    I can't find format description on Facebook concerning the question.
    Can you help me?
    Thanks.
     
    Last edited: May 16, 2017
  36. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    I am not sure about the Facebook SDK itself. But from our side, we will provide all the fixes according to official Facebook changes. So, please, pay your attention, that you make all these manual changes on your own risk.
     
  37. Fremium

    Fremium

    Joined:
    May 2, 2017
    Posts:
    19
    1. I am experiencing some problems with game data saving using Google Saved Games feature.

    When MakeScreenshotAndSaveGameData() coroutine is started and my game goes to background (due to incoming call or when pressing Home button) GooglePlaySavedGamesManager.ActionGameSaveResult event is never fired after user has returned to my app.

    Can you tell me how to solve this issue and correctly handle the collision?

    2. I need also to handle some events during normally running save operation to allow my app to stop this save operation if needed.

    I found that sometimes GooglePlaySavedGamesManager.ActionGameSaveResult event (for some unknown reasons) is never fired in normal conditions even for simple test app with no complex logic.

    When I restart my app next time, saving is OK (GooglePlaySavedGamesManager.ActionGameSaveResult event is fired as needed).

    I wonder is there any internal timeout when saving data to Google Saved Games?

    I can't find any events for returning results with failures during saving or loading actions.

    3. Anyway I want to create my own event that will be fired if GooglePlaySavedGamesManager.ActionGameSaveResult would not be started in 30 seconds after calling of MakeScreenshotAndSaveGameData() coroutine to stop previous save operation and start new one.

    Can you tell me how can I arrange code logic to make that happen?

    Thanks for your help.
     
    Last edited: May 17, 2017
  38. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    It becomes hard for me to understand the logic of your application.
    I would recommend you to track all the coroutines before application pause and after.
    Check the status of each one and make whatever action you need.
    I am not 100% sure will it be appropriate for your project or not. That's just an advice.

    This case is difficult to track/understand is the forum circumstances.
    The best way is to contact our support engineer and continue the considering this case there.
    You will get great assistance with any case you have.
     
  39. SoftwareGeezers

    SoftwareGeezers

    Joined:
    Jun 22, 2013
    Posts:
    902
    I get an "unable to merge manifests" when building with the official Facebook SDK. When searching for a solution I've found multiple people having this problem over the past few months, but no solution is provided. I contacted Stan's Assets support directly a couple of days ago and haven't had a reply yet, but it makes more sense for a public solution to help others so I'll repeat the problem here and include the solution when found.

    plugin version : 9.6/19
    Google Play SDK : 10.2.1
    Facebook SDK : 7.9.4

    I’ve found 4 manifest files none of which had the minimum API level of 15 that a Google search says is required for Facebook. I’ve changed those from minimum API 14 to 15 and that's solved some of the merge errors, but I still get:

    CommandInvokationFailure: Unable to merge android manifests. See the Console for more details.
    C:/Program Files/Java/jdk1.8.0_91\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="C:/Program Files/Development Stuff/Android/sdk\tools" -Dfile.encoding=UTF8 -jar "C:\Program Files\Development Stuff\Unity 5.6\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" -

    stderr[
    Error: [Temp\StagingArea\AndroidManifest-main.xml:57, D:\_Programming Stuff\Unity\novaWARS\Temp\StagingArea\android-libraries\facebook-android-sdk-4.17.0\AndroidManifest.xml:6] Trying to merge incompatible /manifest/application/activity[@name=com.facebook.FacebookActivity] element:
    <activity
    @android:name="com.facebook.FacebookActivity"
    -- @android:theme="@android:style/Theme.Translucent.NoTitleBar">
    <activity
    @android:name="com.facebook.FacebookActivity"
    ++ @android:theme="@StyLe/com_facebook_activity_theme">
    ]

    stdout[
    [Temp\StagingArea\AndroidManifest-main.xml:47, D:\_Programming Stuff\Unity\novaWARS\Temp\StagingArea\android-libraries\play-services-ads-lite\AndroidManifest.xml:10] Skipping identical /manifest/application/activity[@name=com.google.android.gms.ads.AdActivity] element.
    [Temp\StagingArea\AndroidManifest-main.xml:8, D:\_Programming Stuff\Unity\novaWARS\Temp\StagingArea\android-libraries\play-services-basement\AndroidManifest.xml:5] Skipping identical /manifest/application/meta-data[@name=com.google.android.gms.version] element.
    ]
    exit code: 1
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.Android.AndroidSDKTools.RunCommandInternal (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.Android.AndroidSDKTools.RunCommandSafe (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.HostView:OnGUI()

    I’ve tried toggling Android Native’s ‘keep manifest clean’ option but neither option works. I've tried manually changing the @android:theme line in AN's manifest but nothing works.
     
  40. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    Hello,
    You have minor misconception between the main manifest and the manifest imported with the Facebook SDK.
    I would recommend you to contact our support team for assistance. You will fix this issue in a very short time.
    Please, go ahead. You are welcome!
     
  41. Fremium

    Fremium

    Joined:
    May 2, 2017
    Posts:
    19
    Thanks for advice. It helped to solve the issue.

    I am experiencing some problems during implementation of runtime permissions check.

    I am using AN_PermissionMethods class from AN_Permission.cs file (since there is no
    AN_MenifestPermission class as it is stated in documentation).

    https://unionassets.com/android-native-plugin/runtime-permissions-511

    I've added public modifier since I need to access AN_PermissionMethods class, but I found that code intended for handling KeyValuePair returns build error:

    error CS0718: `AN_PermissionMethods': static classes cannot be used as generic arguments

    Removing static modifier from AN_PermissionMethods class leads to different build error:

    error CS1106: `AN_PermissionMethods.GetFullName(this AN_Permission)': Extension methods must be defined in a non-generic static class

    Can you tell me how to get rid of these errors?
     
  42. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    You should not use AN_PermissionMethods class for your own purposes. That's for internal use ONLY.
    This class contains extension methods for AN_Permission.
     
  43. Fremium

    Fremium

    Joined:
    May 2, 2017
    Posts:
    19
    Can you tell me what should I use instead of AN_MenifestPermission parameter (specified in documentation) since there is no AN_MenifestPermission in Android Native Plugin's code?

    https://github.com/Fremium/AndroidN...ames/blob/master/RuntimePermissionsManager.cs

    If AN_Permission is used instead of AN_MenifestPermission than build error is raised:

    error CS1061: Type `AN_Permission' does not contain a definition for `GetFullName' and no extension method `GetFullName' of type `AN_Permission' could be found (are you missing a using directive or an assembly reference?)
     
    Last edited: May 23, 2017
  44. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    What AN_MenifestPermission are you going to use? This class doesn't exist in our plugin.
     
  45. Fremium

    Fremium

    Joined:
    May 2, 2017
    Posts:
    19
  46. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    The doc is quite old. Should be updated. Please, contact our support engineer for further assistance.
    Thank you!
     
  47. SoftwareGeezers

    SoftwareGeezers

    Joined:
    Jun 22, 2013
    Posts:
    902
    Not so much a minor misconception as no conception at all! These are the instructions from support for others who must have the same issue. I can't believe I'm the only one who's encountered this.

    1. You need to remove support-v4-24.1.1.aar
    2. Set in the AndroidManifest.xml uses-sdk android:minSdkVersion="15"-> value 15.
    3. You need to open plugin settings, hit on Load Example settings.
    4. Then open AndroidManifest.xml by path Plugins -> Android and replace this line:

    <activity android:name="com.facebook.FacebookActivity" android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:theme="@android:style/Theme.Translucent.NoTitleBar" />

    with this:

    <activity android:name="com.facebook.FacebookActivity" android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:theme="@StyLe/com_facebook_activity_theme" />​

    This info probably needs to be in the documentation? They worked for me after I removed Facebook and Android Native from the project and then started again, with Facebook then Android Native. Then I could change the settings from the example project ones to my own Google Play settings.

    Edit: There are further problems. After changing the values to my own project requirements, new manifest conflicts are generated. I've fixed these manually...
    Code (csharp):
    1.  
    2.   <activity
    3.       @android:name="com.facebook.FacebookActivity"
    4. --    @android:theme="@android:style/Theme.Translucent.NoTitleBar">
    5.   <activity
    6.       @android:name="com.facebook.FacebookActivity"
    7. ++    @android:theme="@style/com_facebook_activity_theme">
    8.  
    9.   <meta-data
    10.       @android:name="com.google.android.gms.version"
    11. --    @android:value="10.2.1">
    12.   <meta-data
    13.       @android:name="com.google.android.gms.version"
    14. ++    @android:value="@integer/google_play_services_version">
    15.  
     
    Last edited: May 26, 2017
  48. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    I recommended you to contact our support team for assistance in this case.
    We permanently work on our documentation to make it as much clear as possible.

    It's great, that you fixed this issues on your own.
    If you will have any kind of questions in future, please, feel free to contact our support team.
    You are welcome!
     
  49. SoftwareGeezers

    SoftwareGeezers

    Joined:
    Jun 22, 2013
    Posts:
    902
    Which is great as bad documentation is the bane of us developers! :) Hence my recommendation for the changes. As you say in this thread though, some of the documentation is out-dated. Updating the docs is more effective use of your resources than individual support so I heartily recommend you ensure it's all up to the latest library. That's also why I posted the solution, so other devs searching for the same error will find the advice and not have to trouble your support team directly.
     
  50. AlexRay

    AlexRay

    Joined:
    Jul 9, 2014
    Posts:
    993
    Thank you for your feedback! Appreciate it. Of course, we are trying to do all the best to make the experience of our customers as good as possible. Stay with us and keep looking forward to following updates.
    Wish you good luck!