Ejemplo n.º 1
0
    //直接分享到各个社交平台
    //platform 平台名,text 分享的文字,imagePath 分享的照片文件路径,callback 分享成功或失败的回调

    public static void DirectShare(Platform platform, string text, string imagePath, ShareDelegate callback = null)
    {
        if (string.IsNullOrEmpty(appKey))
        {
            Debug.LogError("请设置appkey");
            return;
        }

#if UNITY_ANDROID
        try
        {
            SetPlatforms(new Platform[] { platform });

            Run(delegate
            {
                var androidShareListener = new AndroidShareListener(callback);
                UMSocialSDK.CallStatic("directShare", text, imagePath, (int)platform, androidShareListener);
            });
        }

        catch (AndroidJavaException exp)
        {
            Debug.LogError(exp.Message);
        }
#elif UNITY_IPHONE
        shareDelegate = callback;
        directShare(text, imagePath, (int)platform, ShareCallback);
#endif
    }
Ejemplo n.º 2
0
    //打开分享面板
    //platforms 需要分享的平台数组 ,text 分享的文字, imagePath 分享的照片文件路径, callback 分享成功或失败的回调
    //imagePath可以为url 但是url图片必须以http://或者https://开头
    //imagePath如果为本地文件 只支持 Application.persistentDataPath下的文件
    //例如 Application.persistentDataPath + "/" +"你的文件名"
    //如果想分享 Assets/Resouces的下的 icon.png 请前使用 Resources.Load() 和 FileStream 写到 Application.persistentDataPath下
    public static void OpenShareWithImagePath(Platform[] platforms, string text, string imagePath, string title, string targeturl, ShareDelegate callback = null)
    {
        if (platforms == null)
        {
            Debug.LogError("平台不能为空");
            return;
        }
        //var _platforms = platforms ?? Enum.GetValues(typeof(Platform)) as Platform[];
        var length       = platforms.Length;
        var platformsInt = new int[length];

        for (int i = 0; i < length; i++)
        {
            platformsInt[i] = (int)platforms[i];
        }

#if UNITY_ANDROID
        try
        {
            Run(delegate
            {
                var androidShareListener = new AndroidShareListener(callback);
                UMSocialSDK.CallStatic("openShareWithImagePath", platformsInt, text, imagePath, title, targeturl, androidShareListener);
            });
        }
        catch (AndroidJavaException exp)
        {
            Debug.LogError(exp.Message);
        }
#elif UNITY_IPHONE
        shareDelegate = callback;
        openShareWithImagePath(platformsInt, length, text, imagePath, title, targeturl, ShareCallback);
#endif
    }
Ejemplo n.º 3
0
    //直接分享到各个社交平台
    //platform 平台名,text 分享的文字,imagePath 分享的照片文件路径,callback 分享成功或失败的回调

    public static void DirectShare(Platform platform, string text, string imagePath, string title, string targeturl, ShareDelegate callback = null)
    {
#if UNITY_ANDROID
        try
        {
            // SetPlatforms(new Platform[] { platform });

            Run(delegate
            {
                var androidShareListener = new AndroidShareListener(callback);
                UMSocialSDK.CallStatic("directShare", text, imagePath, title, targeturl, (int)platform, androidShareListener);
            });
        }

        catch (AndroidJavaException exp)
        {
            Debug.LogError(exp.Message);
        }
#elif UNITY_IPHONE
        shareDelegate = callback;
        directShare(text, imagePath, title, targeturl, (int)platform, ShareCallback);
#endif
    }
Ejemplo n.º 4
0
 static extern void directShare(string text, string imagePath, int platform, ShareDelegate callback);
Ejemplo n.º 5
0
 static extern void openShareWithImagePath(int[] platform, int platformNum, string text, string imagePath, ShareDelegate callback);
Ejemplo n.º 6
0
 public AndroidShareListener(ShareDelegate Delegate)
     : base("com.umeng.socialsdk.UMSocialSDK$ShareListener")
 {
     this.shareDelegate = Delegate;
 }