Skip to content

Commit

Permalink
Merge pull request #9 from plaidev/release/1.0.3
Browse files Browse the repository at this point in the history
release 1.0.3
  • Loading branch information
kota authored Mar 31, 2023
2 parents 3d6f695 + 59d9c74 commit c6051df
Show file tree
Hide file tree
Showing 30 changed files with 362 additions and 270 deletions.
Binary file modified KarteSDK.unitypackage
Binary file not shown.
Binary file modified Unity/Assets/Plugins/.DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions Unity/Assets/Plugins/Android/baseProjectTemplate.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ allprojects {
buildscript {
repositories {**ARTIFACTORYREPOSITORY**
google()
jcenter()
mavenCentral()
}

dependencies {
Expand All @@ -19,7 +19,7 @@ allprojects {

repositories {**ARTIFACTORYREPOSITORY**
google()
jcenter()
mavenCentral()
flatDir {
dirs "${project(':unityLibrary').projectDir}/libs"
}
Expand Down
72 changes: 0 additions & 72 deletions Unity/Assets/Plugins/Android/mainTemplate.gradle.DISABLED

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
34 changes: 21 additions & 13 deletions Unity/Packages/io.karte.unity/Runtime/src/App.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#if UNITY_IOS && !UNITY_EDITOR
using System.Runtime.InteropServices;
#endif
using Newtonsoft.Json.Linq;
using System;
using UnityEngine;

namespace Io.Karte { /// <summary>
/// <para>SDK全体に影響のある機能を扱うクラスです。</para>
/// </summary>
public class App {
namespace Io.Karte
{ /// <summary>
/// <para>SDK全体に影響のある機能を扱うクラスです。</para>
/// </summary>
public class App
{
#if UNITY_IOS && !UNITY_EDITOR
[DllImport ("__Internal")]
static extern string KRTApp_getVisitorId ();
Expand All @@ -31,7 +33,8 @@ public class App {
/// ビジターIDを返します。
/// </summary>
/// <returns>ビジターIDを返します。</returns>
public static string GetVisitorId () {
public static string GetVisitorId()
{
string visitorId = "";
#if UNITY_IOS && !UNITY_EDITOR
visitorId = KRTApp_getVisitorId ();
Expand All @@ -47,7 +50,8 @@ public static string GetVisitorId () {
/// <para>なお登録時に plugin_native_app_identify イベントを発行します。</para>
/// </summary>
/// <param name="token">FCMトークン </param>
public static void RegisterFCMToken (string token) {
public static void RegisterFCMToken(string token)
{
#if UNITY_IOS && !UNITY_EDITOR
KRTApp_registerFCMToken (token);
#elif UNITY_ANDROID && !UNITY_EDITOR
Expand All @@ -56,7 +60,7 @@ public static void RegisterFCMToken (string token) {
#endif
}

/// <summary>
/// <summary>
/// <para>ビジターIDの再生成処理を行います。</para>
/// <para>なお内部では、以下の処理が行われます。
/// <list type="bullet">
Expand All @@ -67,7 +71,8 @@ public static void RegisterFCMToken (string token) {
/// </list>
/// </para>
/// </summary>
public static void RenewVisitorId () {
public static void RenewVisitorId()
{
#if UNITY_IOS && !UNITY_EDITOR
KRTApp_renewVisitorId ();
#elif UNITY_ANDROID && !UNITY_EDITOR
Expand All @@ -81,7 +86,8 @@ public static void RenewVisitorId () {
/// <para>オプトアウト実行後、計測をはじめとしたSDKの内部処理は全て無効化されます。</para>
/// <para>optInを実行することでオプトアウト状態を解除できます。</para>
/// </summary>
public static void OptOut () {
public static void OptOut()
{
#if UNITY_IOS && !UNITY_EDITOR
KRTApp_optOut ();
#elif UNITY_ANDROID && !UNITY_EDITOR
Expand All @@ -93,7 +99,8 @@ public static void OptOut () {
/// <summary>
/// オプトアウト状態を解除します。
/// </summary>
public static void OptIn () {
public static void OptIn()
{
#if UNITY_IOS && !UNITY_EDITOR
KRTApp_optIn ();
#elif UNITY_ANDROID && !UNITY_EDITOR
Expand All @@ -102,10 +109,11 @@ public static void OptIn () {
#endif
}

/// <summary>
/// <summary>
/// KarteでURLを処理します。
/// </summary>
public static bool OpenUrl (string url) {
public static bool OpenUrl(string url)
{
#if UNITY_IOS && !UNITY_EDITOR
return KRTAPP_openURL (url);
#elif UNITY_ANDROID && !UNITY_EDITOR
Expand Down
76 changes: 46 additions & 30 deletions Unity/Packages/io.karte.unity/Runtime/src/CallbackReceiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,81 +2,97 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEditor;
using System.Text;

[assembly : InternalsVisibleTo ("EditModeTest")]
namespace Io.Karte {
internal class CallbackReceiver : MonoBehaviour {
private  Dictionary<string, Action<bool>> variablesCallbacks = new Dictionary<string, Action<bool>> ();
[assembly: InternalsVisibleTo("EditModeTest")]
namespace Io.Karte
{
internal class CallbackReceiver : MonoBehaviour
{
private Dictionary<string, Action<bool>> variablesCallbacks = new Dictionary<string, Action<bool>>();
public static CallbackReceiver Instance;
public static string CallbackTargetName = "KarteCallbackReceiverObject";
private static GameObject attachedGameObject;

[Serializable]
private class VariablesCallbackArgument {
private class VariablesCallbackArgument
{
#pragma warning disable 649
public string callbackId;
public bool result;
}

[Serializable]
private class OpenUrlWithSceneCallbackArgument {
[Serializable]
private class OpenUrlWithSceneCallbackArgument
{
#pragma warning disable 649
public string url;
public string sceneIdentifier;
}

[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
static void Init(){
static void Init()
{
SetupCallbackReceiver();
}

public CallbackReceiver () {
public CallbackReceiver()
{
Instance = this;
}

public void VariableCallback (string message) {
VariablesCallbackArgument arg = JsonUtility.FromJson<VariablesCallbackArgument> (message);
public void VariableCallback(string message)
{
VariablesCallbackArgument arg = JsonUtility.FromJson<VariablesCallbackArgument>(message);
Action<bool> callback;
try {
try
{
callback = variablesCallbacks[arg.callbackId];
variablesCallbacks.Remove (arg.callbackId);
callback (arg.result);
} catch (KeyNotFoundException) {
variablesCallbacks.Remove(arg.callbackId);
callback(arg.result);
}
catch (KeyNotFoundException)
{
return;
}
}

internal void AddVariablesCallback (string callbackId, Action<bool> callback) {
variablesCallbacks.Add (callbackId, callback);
internal void AddVariablesCallback(string callbackId, Action<bool> callback)
{
variablesCallbacks.Add(callbackId, callback);
}

public void InAppMessagingOpenUrlCallback(string message) {
public void InAppMessagingOpenUrlCallback(string message)
{
InAppMessaging.InvokeOpenUrlHandler(message);
}

public void InAppMessagingOpenUrlWithSceneCallback(string message) {
OpenUrlWithSceneCallbackArgument arg = JsonUtility.FromJson<OpenUrlWithSceneCallbackArgument> (message);
public void InAppMessagingOpenUrlWithSceneCallback(string message)
{
OpenUrlWithSceneCallbackArgument arg = JsonUtility.FromJson<OpenUrlWithSceneCallbackArgument>(message);
InAppMessaging.InvokeOpenUrlWithSceneHandler(arg.url, arg.sceneIdentifier);
}

private static void SetupCallbackReceiver () {
if (attachedGameObject) {
private static void SetupCallbackReceiver()
{
if (attachedGameObject)
{
return;
}
attachedGameObject = new GameObject (CallbackTargetName);
attachedGameObject.AddComponent<CallbackReceiver> ();
attachedGameObject = new GameObject(CallbackTargetName);
attachedGameObject.AddComponent<CallbackReceiver>();
DontDestroyOnLoad(attachedGameObject);
}

public static string GenerateUniqueCallbackID () {
StringBuilder sb = new StringBuilder ("", 16);
public static string GenerateUniqueCallbackID()
{
StringBuilder sb = new StringBuilder("", 16);
const string glyphs = "abcdefghijklmnopqrstuvwxyz0123456789";
for (int i = 0; i < 16; i++) {
sb.Append (glyphs[UnityEngine.Random.Range (0, glyphs.Length)]);
for (int i = 0; i < 16; i++)
{
sb.Append(glyphs[UnityEngine.Random.Range(0, glyphs.Length)]);
}
return sb.ToString ();
return sb.ToString();
}
}
}
Loading

0 comments on commit c6051df

Please sign in to comment.