anchan828 / social-connector

Social Connector
zlib License
148 stars 51 forks source link

Social Connector v0.5.0

Android/iOSで、様々なアプリと連携を行いゲームスコアなどをシェアするプラグイン。

注意:

Requirements

iOS

Android

使い方

SocialConnector.Share("Social Connector", "https://github.com/anchan828/social-connector", imagePath);

サンプル

See Assets/Plugins/SocialConnector/Sample/Sample.cs

using UnityEngine;

namespace SocialConnector
{
    public class Sample : MonoBehaviour
    {
        string imagePath {
            get {
                return Application.persistentDataPath + "/image.png";
            }
        }

        void OnGUI ()
        {

            if (GUILayout.Button ("<size=30><b>Take</b></size>", GUILayout.Height (60))) {
                Application.CaptureScreenshot ("image.png");
            }

            GUILayout.Space (60);

            ///=================
            /// Share
            ///=================

            if (GUILayout.Button ("<size=30><b>Share</b></size>", GUILayout.Height (60))) {
                SocialConnector.Share ("Social Connector", "https://github.com/anchan828/social-connector", null);
            }
            if (GUILayout.Button ("<size=30><b>Share Image</b></size>", GUILayout.Height (60))) {
                SocialConnector.Share ("Social Connector", "https://github.com/anchan828/social-connector", imagePath);
            }
        }
    }
}

FileProviderに対応する

Android API Level 24 から、画像のシェアにおいて FileProvider の使用が必須となりました。このため、プロジェクト単位で AndroidManifest.xml をカスタマイズしなければいけません。

Social Connectorが用意したAndroidManifest.xmlを使用する

実装例としてSocialConnector/Plugins/Androidフォルダー配下にAndroidManifest.xmlを配置しています。 以下の手順に沿うことで、FileProviderに対応することが可能です。

  1. SocialConnector/Plugins/AndroidフォルダーをPlugins/Androidフォルダーに移動する
  2. AndroidManifest.xml内のcom.kyusyukeigo.socialconnector.fileproviderをプロジェクトのパッケージ名に書き換える。(例: パッケージ名がcom.example.gameであれば com.example.game.fileproviderに書き換える)
    • パッケージ名は、Player SettingsのIdentificationApplication.identifierで確認することができます。

トラブルシューティング

もし、何かしらのエラーが起きた場合 support-core-utils-25.3.1.aar を削除してみてください。ライブラリの競合が解決し、ビルドが通るかもしれません。

Advanced

技術的なお話

このプラグインは、次の技術を使用しています。

ACTION_SENDUIActivityViewController は不特定多数のアプリに対してシェアを行うための機能です。特定のアプリに対してのシェアをサポートしているわけではないということに注意してください。

更新履歴

v0.5.0

v0.4.1

v0.4.0

ライセンス

Copyright (C) 2011 Keigo Ando

This software is provided 'as-is', without any express or implied
warranty.  In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not
   claim that you wrote the original software. If you use this software
   in a product, an acknowledgment in the product documentation would be
   appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
   misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.