Open Youtube and Tumblr link in app rather than browser - Unity

倖福魔咒の 提交于 2019-12-24 18:03:21

问题


I've managed to make it so when clicking specific buttons it loads up Facebook, Twitter and Instagram using fb://------, twitter://---- and instagram://-----, but I can't seem to find one for YouTube or Tumblr. Is there any way to do this?

Edit: This is my current code. (Sorry for the slow reply)

// Set buttontype in editor depending on which button it is
// 0 = facebook, 1 = instagram, 2 = tumblr, 3 = twitter, 4 = youtube
public int buttonType;

// Web urls - use this for computers or if the user doesn't have the app installed on phones
private string[] webUrls = { 
    "https://www.facebook.com/-------",
    "https://www.instagram.com/--------",
    "http://--------.tumblr.com/",
    "https://twitter.com/----------",
    "https://youtube.com/user/--------"
};

// Use this for android - loads the app - if don't have the app, default to weburls
private string[] appUrls = {
    "fb://page/--------",
    "instagram://user?username=---------",
    "http://-------.tumblr.com/",
    "twitter://user?user_id=-------",
    "https://youtube.com/user/--------"
}; 

void OnMouseDown()
{
    // Checks which device it's running on - STANDALONE is windows/mac/linux
    #if UNITY_STANDALONE
        Application.OpenURL (webUrls[buttonType]);
    #endif

    #if UNITY_ANDROID
        Application.OpenURL (appUrls[buttonType]);

        // Do a check to see if they have the app installed
        StartCoroutine(CheckApp());
        launchedApp = false;
    #endif

}

// If switched app, set to true so it won't launch the browser
void OnApplicationPause()
{
    launchedApp = true;
}

IEnumerator CheckApp()
{
    // Wait for a time
    yield return new WaitForSeconds (waitTime);

    // If app hasn't launched, default to opening in browser
    if(!launchedApp)
    {
        Application.OpenURL (webUrls[buttonType]);
    }
}

I simply wait a bit, if the app hasn't launched, I open it in the browser on Android.

Also, the normal YouTube link sometimes asks if you want to open it in the app, not all the time which is quite annoying.

Edit: After searching for a hell of a long time, I finally found it.

tumblr://x-callback-url/blog?blogName=BLOGNAME

The full list of social media that I'll be using are:

fb://page/PAGEIDNUMBER
instagram://user?username=USERNAME
tumblr://x-callback-url/blog?blogName=BLOGNAME
twitter://user?user_id=USERID
https://youtube.com/user/USERNAME

Replace the caps with your specific pages. Hope this helps someone.


回答1:


Edit: After searching for a hell of a long time, I finally found it.

tumblr://x-callback-url/blog?blogName=BLOGNAME

The full list of social media that I'll be using are:

fb://page/PAGEIDNUMBER
instagram://user?username=USERNAME
tumblr://x-callback-url/blog?blogName=BLOGNAME
twitter://user?user_id=USERID
https://youtube.com/user/USERNAME

Replace the caps with your specific pages. Hope this helps someone.




回答2:


Using youtu.be/LINK for the youtube allows you to open users, channels and video link.

Hope it helps somebody :)



来源:https://stackoverflow.com/questions/35544165/open-youtube-and-tumblr-link-in-app-rather-than-browser-unity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!