Example #1
0
        internal static void TrackAppOpened(string _pushId)             //(Android/iOS)-NCMBManager.onAnalyticsReceived-this.NCMBAnalytics
        {
            //ネイティブから取得したpushIdからリクエストヘッダを作成
            if (_pushId != null && NCMBManager._token != null && NCMBSettings.UseAnalytics)
            {
                string deviceType = "";
                if (SystemInfo.operatingSystem.IndexOf("Android") != -1)
                {
                    deviceType = "android";
                }
                else if (SystemInfo.operatingSystem.IndexOf("iPhone") != -1)
                {
                    deviceType = "ios";
                }

                //RESTリクエストデータ生成
                Dictionary <string, object> requestData = new Dictionary <string, object> {
                    { "pushId", _pushId },
                    { "deviceToken", NCMBManager._token },
                    { "deviceType", deviceType }
                };

                var         json    = Json.Serialize(requestData);
                string      url     = NCMBAnalytics._getBaseUrl(_pushId);
                ConnectType type    = ConnectType.POST;
                string      content = json.ToString();
                NCMBDebug.Log("content:" + content);
                //ログを確認(通信前)
                NCMBDebug.Log("【url】:" + url + Environment.NewLine + "【type】:" + type + Environment.NewLine + "【content】:" + content);
                // 通信処理
                NCMBConnection con = new NCMBConnection(url, type, content, NCMBUser._getCurrentSessionToken());
                con.Connect(delegate(int statusCode, string responseData, NCMBException error) {
                    try {
                        NCMBDebug.Log("【StatusCode】:" + statusCode + Environment.NewLine + "【Error】:" + error + Environment.NewLine + "【ResponseData】:" + responseData);
                    } catch (Exception e) {
                        error = new NCMBException(e);
                    }
                    return;
                });

                                #if UNITY_IOS
                                        #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7
                NotificationServices.ClearRemoteNotifications();
                                        #else
                UnityEngine.iOS.NotificationServices.ClearRemoteNotifications();
                                        #endif
                                #endif
            }
        }
 //ネイティブからプッシュIDを受け取り開封通知
 private void onAnalyticsReceived(string _pushId)
 {
     NCMBAnalytics.TrackAppOpened(_pushId);
 }