UnityNativeShare icon indicating copy to clipboard operation
UnityNativeShare copied to clipboard

IOS 11.3

Open svisveswar001 opened this issue 7 years ago • 21 comments

Share stopped working with IOS 11.3. The Share dialog box does not appear anymore. Code works fine in older IOS versions.

svisveswar001 avatar Apr 18 '18 03:04 svisveswar001

Do you get a specific error message? Does wrapping lines 31 to 40 with the following solve the issue:

dispatch_async(dispatch_get_main_queue(), ^{
    // lines 31-40
});

Credit: https://stackoverflow.com/a/46832604/2373034

yasirkula avatar Apr 18 '18 07:04 yasirkula

Thanks so much! I tried your suggestion and it worked. But I also found on another iPhone with 11.3 it works without the above change. So I am not even sure what the issue is. I am trying to debug now with and without change on Xcode. I will post an update shortly.

svisveswar001 avatar Apr 18 '18 17:04 svisveswar001

So, did you find anything useful? :)

yasirkula avatar May 23 '18 09:05 yasirkula

I have the same problem when are you going to commit a fix @yasirkula Thanks ;)

chadidi avatar Jun 27 '18 01:06 chadidi

I used the project from unity store and it worked, but why the code is different I downloaded a plugin with same name 1 month ago but when i opened them the code was very different. 🤯

chadidi avatar Jun 27 '18 01:06 chadidi

I don't update Asset Store versions of my plugins very often (guess I'm lazy), but for NativeShare, there shouldn't be much of a difference, if any. Maybe you downloaded a different plugin like this?

yasirkula avatar Jun 27 '18 07:06 yasirkula

@yasirkula Yeah maybe i have downloaded another plugin!!

And also I have another problem is that it's not working on android. but when i test it on Unity Editor i can see in the log that it prints 'Shared'. This is my method public void Share() { NativeShare myNativeShare = new NativeShare(); if (myNativeShare == null) { Debug.Log("shared failed(?)"); return; } myNativeShare.SetTitle("Share our new phone with the world"); myNativeShare.AddFile(filePath); myNativeShare.Share(); }

chadidi avatar Jun 27 '18 12:06 chadidi

Does the share dialog not show at all on Android? If so, are there any error messages on Logcat? After you build your project to Android, can you navigate to PROJECT_PATH/Temp/StagingArea/AndroidManifest.xml and copy&paste its <provider ... /> tag here?

P.S. It would be better to open a new issue the next time to keep things more organized.

yasirkula avatar Jun 27 '18 12:06 yasirkula

@yasirkula After i build the code removed from the file and still the same should i add it to AndroidManifest-main.xml

chadidi avatar Jun 27 '18 12:06 chadidi

The provider tag must be placed inside Assets/Plugins/Android/AndroidManifest.xml. If your AndroidManifest is located elsewhere, you should move it to Assets/Plugins/Android/.

yasirkula avatar Jun 27 '18 13:06 yasirkula

Hi! First of all, many thanks for the plugin! I have tested it on iOS 11.4 and it does not work even adding the "dispatch_async" code. Any solution? Thanks in advance!

bigvanstudio avatar Jul 05 '18 12:07 bigvanstudio

Are there any error messages in the console? And are you testing on an iPhone or an iPad?

yasirkula avatar Jul 05 '18 13:07 yasirkula

Hi, Thanks for your fast reply. I am testing in on an iPhone 7. I am trying to share a just recorded video. Thanks for yr support. This is what I see on the console:

Share video. Path:/var/mobile/Containers/Data/Application/4D665B07-56F9-497D-8FEB-BF8CBAAE7A7D/Documents/recording_2018_07_05_16_11_08_554.mov

UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object) UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[]) UnityEngine.Logger:Log(LogType, Object) UnityEngine.Debug:Log(Object) RecordVideoNatCorder:ShareVideo() UnityEngine.Events.UnityAction:Invoke() UnityEngine.Events.InvokableCall:Invoke() UnityEngine.Events.UnityEvent:Invoke() UnityEngine.UI.Button:Press() UnityEngine.UI.Button:OnPointerClick(PointerEventData) UnityEngine.EventSystems.ExecuteEvents:Execute(IPointerClickHandler, BaseEventData) UnityEngine.EventSystems.EventFunction1:Invoke(T1, BaseEventData) UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction1) UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean) UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents() UnityEngine.EventSystems.StandaloneInputModule:Process() UnityEngine.EventSystems.EventSystem:Update()

(Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

bigvanstudio avatar Jul 05 '18 14:07 bigvanstudio

What happens when you try to share the video? Does the share dialog not show up at all? If the dialog does show up, try sharing without any text/subject and see if it changes anything. Also insert Debug.Log( "Video exists: " + File.Exists( videoPath ) ); to your script and see if it returns true (maybe processing the video takes a couple of seconds). Can I also see your ShareVideo function? Thanks!

yasirkula avatar Jul 05 '18 14:07 yasirkula

Nothing happens.. This is the ShareVideo function:

public void ShareVideo(){ Debug.Log("Share video. Path:" + GlobalVariables.lastVideoPath); Debug.Log("Video exists: " + File.Exists(GlobalVariables.lastVideoPath)); //new NativeShare().AddFile(GlobalVariables.lastVideoPath).SetSubject("Subject text").SetText("Hello World!"); new NativeShare().AddFile(GlobalVariables.lastVideoPath); }

This is what I see on the console when the function is called:

Share video. Path:/var/mobile/Containers/Data/Application/4291CAD2-E57E-410A-BF57-5303A3EE2237/Documents/recording_2018_07_05_16_41_33_064.mov Video exists: True UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object) UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[]) UnityEngine.Logger:Log(LogType, Object) UnityEngine.Debug:Log(Object) RecordVideoNatCorder:ShareVideo() UnityEngine.Events.UnityAction:Invoke() UnityEngine.Events.InvokableCall:Invoke() UnityEngine.Events.UnityEvent:Invoke() UnityEngine.UI.Button:Press() UnityEngine.UI.Button:OnPointerClick(PointerEventData) UnityEngine.EventSystems.ExecuteEvents:Execute(IPointerClickHandler, BaseEventData) UnityEngine.EventSystems.EventFunction1:Invoke(T1, BaseEventData) UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction1) UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean) UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents() UnityEngine.EventSystems.StandaloneInputModule:Process() UnityEngine.EventSystems.EventSystem:Update()

(Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

bigvanstudio avatar Jul 05 '18 14:07 bigvanstudio

You need to add Share(); to the end of the NativeShare object; e.g. new NativeShare().AddFile(GlobalVariables.lastVideoPath).Share();

yasirkula avatar Jul 05 '18 14:07 yasirkula

WOW!! What a rookie's mistake! I apologize!! It works perfectly well!! Many, many thanks!! really!

bigvanstudio avatar Jul 05 '18 15:07 bigvanstudio

You are welcome!

yasirkula avatar Jul 05 '18 15:07 yasirkula

A little late, but I had some initial trouble with sharing a simple text file on iOS 11.3, and it turned out that I needed to include the mime type when declaring specifying the file.

Also, on iOS 13, the code seems to run just great.

gblikas avatar Nov 27 '19 06:11 gblikas

I'm happy to hear that but still a little confused because the mime parameter is not used on iOS: https://github.com/yasirkula/UnityNativeShare/blob/adb30521ac7ed0d0fecad643efbfe2bdd70ea6db/Plugins/NativeShare/NativeShare.cs#L125-L128

yasirkula avatar Nov 27 '19 15:11 yasirkula

Haha, I actually changed the file extension I think. I went from a .log to a .txt, and it gave me a few more options for sharing, most of which work.

gblikas avatar Nov 28 '19 05:11 gblikas