public void Share() { if (files.Count == 0 && subject.Length == 0 && text.Length == 0 && url.Length == 0) { Debug.LogWarning("Share Error: attempting to share nothing!"); return; } #if UNITY_EDITOR Debug.Log("Shared!"); if (callback != null) { callback(ShareResult.Shared, null); } #elif UNITY_ANDROID AJC.CallStatic("Share", Context, new NSShareResultCallbackAndroid(callback), targetPackages.ToArray(), targetClasses.ToArray(), files.ToArray(), mimes.ToArray(), subject, CombineURLWithText(), title); #elif UNITY_IOS NSShareResultCallbackiOS.Initialize(callback); if (files.Count == 0) { _NativeShare_Share(new string[0], 0, subject, text, GetURLWithScheme()); } else { // While sharing both a URL and a file, some apps either don't show up in share sheet or omit the file // If we append URL to text, the issue is resolved for at least some of these apps _NativeShare_Share(files.ToArray(), files.Count, subject, CombineURLWithText(), ""); } #else Debug.LogWarning("NativeShare is not supported on this platform!"); #endif }
public void Share() { if (files.Count == 0 && subject.Length == 0 && text.Length == 0) { Debug.LogWarning("Share Error: attempting to share nothing!"); return; } #if UNITY_EDITOR Debug.Log("Shared!"); if (callback != null) { callback(ShareResult.Shared, null); } #elif UNITY_ANDROID AJC.CallStatic("Share", Context, new NSShareResultCallbackAndroid(callback), targetPackages.ToArray(), targetClasses.ToArray(), files.ToArray(), mimes.ToArray(), subject, text, title); #elif UNITY_IOS NSShareResultCallbackiOS.Initialize(callback); _NativeShare_Share(files.ToArray(), files.Count, subject, text); #else Debug.LogWarning("NativeShare is not supported on this platform!"); #endif }