/NcmbUnityTwitterPlugin

Primary LanguageObjective-CApache License 2.0Apache-2.0

NcmbUnityTwitterPlugin

Overview

NcmbUnityTwitterPlugin is a plugin which support NcmbUnity's signin with Twitter on Android and iOS. This plugin using assets from NcmbUnityAndroidTwitterPlugin for Android and STTwitter for iOS.

  • Note: This plugin is create base on NCMB Unity version 4.4.1

Plugin installation

There are two options available to install this plugin. Either using the Unity Package Manager, or the traditional .unitypackage file.

Unity Package Manager

Install via Git URL. Available starting from Unity 2018.3.

Just add this line to the Packages/manifest.json file of your Unity Project:

"dependencies": {
    "com.nifcloud.mbaas.unity.twitter": "https://github.com/NIFCLOUD-mbaas/NcmbUnityTwitterPlugin.git?path=/ncmb_unity_twitter_plugin/Assets"
}

Unity Package File

  • Please open the release page of Github from the link below and download NcmbUnityTwitterPlugin.x.x.x.zip (x is the version number) Github release page

  • Unzip the zip file and Double-click "NcmbUnityTwitterPlugin.unitypackage" in the folder to import.

Usage

void Start()
{
    // sample SCHEME = myapp://
    NCMBOAuthTwitter.Init("TWITTER_KEY", "TWITTER_SECRET_KEY", "SCHEME");
}

// Update is called once per frame
void Update()
{

}
public void pressMe()
{
    INCMBTwitterCallback callback = new CallbackTwitter();
    NCMBOAuthTwitter.LogIn(callback);
    Debug.Log("Call login here....");
}

private class CallbackTwitter : INCMBTwitterCallback
{
    public void OnFailure(string errorMessage)
    {
        Debug.Log("errorMessage: " + errorMessage);
    }

    public void OnSuccess(string id, string userName, string token, string tokenSecret)
    {
        NCMBTwitterParameters parameters = new NCMBTwitterParameters(
            id.ToString(),
            userName,
            "TWITTER_KEY",
            "TWITTER_SECRET_KEY",
            token,
            tokenSecret
        );
        NCMBUser user = new NCMBUser();
        user.AuthData = parameters.param;
        //ニフクラ mobile backendにログイン
        user.LogInWithAuthDataAsync((NCMBException e) =>
        {
            Debug.Log("Login successfully!");
        });
        
    }
}

For Developer

If you want to change the assets, please follow step:

  • For Anroid: Please change your logic at NcmbUnityAndroidTwitterPlugin after that replace the arr file in this project.
  • For iOS: Please change your logic at STTwitter and replace STTwitter assets in this project.

License

The NcmbUnityTwitterPlugin is licensed under the Apache License 2.0. See the LICENSE file for more details.