narancs
narancs

Reputation: 5294

Unity start Instagram with data

I made the Unity app to start Instagram, when I press a button. I would like not only to start the app, but also load my company's Instagram page.

Is there any idea,how can I do it ? I need this solution for android as well as on iOS.

Thanks,

This is how I start the Android Apps:

        #if UNITY_ANDROID
    AndroidJavaObject launchIntent = null;
    AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    AndroidJavaObject ca = up.GetStatic<AndroidJavaObject>("currentActivity");
    AndroidJavaObject packageManager = ca.Call<AndroidJavaObject>("getPackageManager");
    bool fail= false;

    try
    {
        if(bundleId==null){
            fail = true;
        }else{
            launchIntent = packageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage",bundleId);
        }
    }
    catch (System.Exception e)
    {
        fail = true;
    }

    if (fail)
    { //open app in store
        Application.OpenURL(appStoreLink);
    }
    else //open the app
        ca.Call("startActivity",launchIntent);
    #endif

Upvotes: 0

Views: 1853

Answers (1)

B4lto
B4lto

Reputation: 96

Instagram uses custom url scheme to provide opening their app on device. So all you need to do, is call instagram://user?username=YOURINSTAGRAMPAGE as url.

See https://developers.facebook.com/docs/instagram/sharing-to-feed/

Upvotes: 3

Related Questions