Пример #1
0
    //解除某平台授权
    //platform 平台名 callback 解除完成回调
    public static void DeleteAuthorization(Platform platform, AuthDelegate callback = null)
    {
        if (string.IsNullOrEmpty(appKey))
        {
            Debug.LogError("请设置appkey");
            return;
        }
#if UNITY_ANDROID
        try
        {
            Run(delegate
            {
                var androidAuthListener = new AndroidAuthListener(callback);
                UMSocialSDK.CallStatic("deleteAuthorization", (int)platform, androidAuthListener);
            }
                );
        }
        catch (AndroidJavaException exp)
        {
            Debug.LogError(exp.Message);
        }
#elif UNITY_IPHONE
        authDelegate = callback;
        deleteAuthorization((int)platform, AuthCallback);
#endif
    }
Пример #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
    }
Пример #3
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
    }
Пример #4
0
    //打开SDK的log输出
    public static void OpenLog(bool isEnabled)
    {
#if UNITY_ANDROID
        UMSocialSDK.CallStatic("openLog", isEnabled);
#elif UNITY_IPHONE
        openLog(isEnabled?1:0);
#endif
    }
Пример #5
0
    //设置用户点击一条图文分享时用户跳转到的目标页面, 一般为app主页或者下载页面
    public static void SetTargetUrl(string targetUrl)
    {
#if UNITY_ANDROID
        UMSocialSDK.CallStatic("setTargetUrl", targetUrl);
#elif UNITY_IPHONE
        setTargetUrl(targetUrl);
#endif
    }
Пример #6
0
    //是否已经授权某平台
    //platform 平台名
    public static bool IsAuthorized(Platform platform)
    {
#if UNITY_ANDROID
        return(UMSocialSDK.CallStatic <bool>("isAuthorized", (int)platform));
#elif UNITY_IPHONE
        return(isAuthorized((int)platform));
#else
        return(false);
#endif
    }
Пример #7
0
    //设置SDK的appkey
    public static void SetAppKey(string appKey)
    {
        if (!string.IsNullOrEmpty(appKey))
        {
            Social.appKey = appKey;
#if UNITY_ANDROID
            UMSocialSDK.CallStatic("setAppKey", appKey);
#elif UNITY_IPHONE
            setAppKey(appKey);
            initUnitySDK("Unity", "1.1");
#endif
        }
    }
Пример #8
0
    public static void SupportSSO(Platform platform, string redirectURL)
    {
#if UNITY_ANDROID
        try
        {
            UMSocialSDK.CallStatic("supportSso", (int)platform, redirectURL);
        }
        catch (AndroidJavaException exp)
        {
            Debug.LogError(exp.Message);
        }
#elif UNITY_IPHONE
        openSSOAuthorization((int)platform, redirectURL);
#endif
    }
Пример #9
0
    public static void SetWechatAppIdAndSecret(String appId, String secret)
    {
#if UNITY_ANDROID
        try
        {
            UMSocialSDK.CallStatic("setWechatAppIdAndSecret", appId, secret);
        }
        catch (AndroidJavaException exp)
        {
            Debug.LogError(exp.Message);
        }
#elif UNITY_IPHONE
        setWechatAppId(appId, secret);
#endif
    }
Пример #10
0
    //设置易信appid
    public static void SetYiXinAppKey(string appId)
    {
#if UNITY_ANDROID
        try
        {
            UMSocialSDK.CallStatic("setYiXinAppKey", appId);
        }
        catch (AndroidJavaException exp)
        {
            Debug.LogError(exp.Message);
        }
#elif UNITY_IPHONE
        setYiXinAppKey(appId);
#endif
    }
Пример #11
0
    //设置来往appid,appkey
    //appName 应用名称
    public static void SetLaiwangAppInfo(string appId, string appKey, string appName)
    {
#if UNITY_ANDROID
        try
        {
            UMSocialSDK.CallStatic("setLaiwangAppInfo", appId, appKey, appName);
        }
        catch (AndroidJavaException exp)
        {
            Debug.LogError(exp.Message);
        }
#elif UNITY_IPHONE
        setLaiwangAppInfo(appId, appKey, appName);
#endif
    }
Пример #12
0
    //是否已经授权某平台
    //platform 平台名
    public static bool IsAuthorized(Platform platform)
    {
        if (string.IsNullOrEmpty(appKey))
        {
            Debug.LogError("请设置appkey");
            return(false);
        }

#if UNITY_ANDROID
        return(UMSocialSDK.CallStatic <bool>("isAuthorized", (int)platform));
#elif UNITY_IPHONE
        return(isAuthorized((int)platform));
#else
        return(false);
#endif
    }
Пример #13
0
    public static void SetPlatformShareContent(Platform platform, String text, String imagePath,
                                               String title = null, String targetUrl = null)
    {
#if UNITY_ANDROID
        try
        {
            UMSocialSDK.CallStatic("setPlatformShareContent", (int)platform, text, imagePath, title, targetUrl);
        }
        catch (AndroidJavaException exp)
        {
            Debug.LogError(exp.Message);
        }
#elif UNITY_IPHONE
        setPlatformShareContent((int)platform, text, imagePath, title, targetUrl);
#endif
    }
Пример #14
0
    //设置SDK支持的平台
    public static void SetPlatforms(Platform[] platforms)
    {
        if (string.IsNullOrEmpty(appKey))
        {
            Debug.LogError("请设置appkey");
            return;
        }
        var length       = platforms.Length;
        var platformsInt = new int[length];

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

        Run(delegate
        {
            UMSocialSDK.CallStatic("setPlatforms", platformsInt);
        });
    }
Пример #15
0
 public static void setDismissDelegate(ShareBoardDismissDelegate callback = null)
 {
             #if UNITY_ANDROID
     try
     {
         Run(delegate
         {
             var AndroidDismissListener = new AndroidDismissListener(callback);
             UMSocialSDK.CallStatic("setDismissCallBack", AndroidDismissListener);
         });
     }
     catch (AndroidJavaException exp)
     {
         Debug.LogError(exp.Message);
     }
             #elif UNITY_IPHONE
     dismissDelegate = callback;
     setDismissCallback(ShareBoardCallback);
             #endif
 }
Пример #16
0
    //授权某社交平台
    //platform 平台名 callback 授权成功完成
    public static void Authorize(Platform platform, AuthDelegate callback = null)
    {
#if UNITY_ANDROID
        try
        {
            SetPlatforms(new Platform[] { platform });
            Run(delegate
            {
                var androidAuthListener = new AndroidAuthListener(callback);
                UMSocialSDK.CallStatic("authorize", (int)platform, androidAuthListener);
            });
        }
        catch (AndroidJavaException exp)
        {
            Debug.LogError(exp.Message);
        }
#elif UNITY_IPHONE
        authDelegate = callback;
        authorize((int)platform, AuthCallback);
#endif
    }
Пример #17
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
    }