Back to top

MAJIN SDKドキュメント

  • MAJIN SDKのプッシュ配信機能を利用する際の実装手順及び各APIの仕様です。

MAJIN SDK for Android

Android SDK Readme

SDK の概要

MAJIN の以下の機能を Android アプリから利用するための SDK です。

  1. MAJIN のプッシュ通知機能
    Firebase Cloud Messaging の通知機能を利用します。

  2. MAJIN のログ機能
    起動ログ、ページビュー、カスタム属性をMAJINに送信します。
    アプリからSDKを通じて送信できるデータは、プッシュ配信のセグメント作成に利用するためのデータとなります。

組み込みに必要なもの

アプリケーションの登録

事前に MAJIN の管理コンソールからアプリの登録をしてください。

詳細はこちら

Firebase へのアプリ登録

Firebase の管理コンソールからアプリの登録をしてください。

MAJIN SDK のダウンロード

以下のリンクからダウンロードしてください。

動作環境

本SDKの組み込みに対応しているAndroid OSバージョンは以下の通りです。

MAJIN-Android-SDK 1.2.1

Android 4.4以上
Firebase Cloud Messagingバージョン: 20.1.1以上
※ Android Xへの移行が必須です。

開発環境

Android Studio

インストール

Android プロジェクトへの組み込み方法は以下のリンクを参照してください。

SDKインストール方法

SDK の使い方

SDKの使い方

API

API

Android SDK のインストール

プロジェクトへの追加

ダウンロードしたファイルを解凍し、以下のファイルをプロジェクトのlibsフォルダ以下に追加します。

  • MAJIN.aar

build.gradle の設定

プロジェクトのルートの build.gradledependencies に以下を追記します。

dependencies {
    // 他の設定
    compile 'com.google.gms:google-services:4.3.13'
}
repositories {
    google() // Google's Maven repository
}

モジュールレベルの build.gradlecom.google.gms.google-services を加えます。

plugins {
…
   id 'com.google.gms.google-services'
 …
}

また、dependencies の項目に以下の行を追記します。

implementation 'com.google.firebase:firebase-messaging:23.0.8'
implementation 'com.google.firebase:firebase-core:21.1.1'
implementation (fileTree(dir:'libs',include:['MAJIN_1.2.1.aar']))

※ firebase SDKは、記載されたバージョンで動作確認を行っております。

上記で MAJIN.aar の読み込みに失敗する場合、repositoriesに以下を加えてください。

flatDir {
    dirs 'libs'
}

AndroidManifest.xml の設定

プロジェクトの AndroidManifest.xml ファイルに以下の記述を追加します。

以下の uses-permission の記述を加えます。

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

<application></application> 内に以下を追記します。

<receiver android:name="jp.co.geniee.sdk.messaging.LaunchActionReceiver" android:exported="false">
    <intent-filter>
        <action android:name="jp.co.geniee.sdk.messaging.action.launch_from_push" />
        <action android:name="jp.co.geniee.sdk.messaging.action.launch_from_local_push" />
        <action android:name="jp.co.geniee.sdk.messaging.action.launch_cancel" />
    </intent-filter>
</receiver>

<service
    android:name="jp.co.geniee.sdk.messaging.MaNotificationListenerService"
    android:exported="false" >
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
</service>
<service
    android:name="jp.co.geniee.sdk.messaging.FcmNotificationTokenService"
    android:exported="true" >
    <intent-filter>
        <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
    </intent-filter>
</service>

google-services.json の追加

アプリを Firebase に登録していると、登録後に google-services.json というファイルをダウンロードできます。

登録は以下から行います。

ダウンロードした google-services.json ファイルを、アプリプロジェクト内に追加しておきます。

Proguard設定

Proguardを使用してファイルの難読化と圧縮を行う場合、以下に従って設定を追加してください。

MAJIN SDKの設定

-keep public class jp.co.geniee.sdk.messaging.** {
  public *;
}

FCMライブラリの設定

AndroidStudioで開発をしている場合、FCMライブラリについてProguardの設定をする必要はありません。 その他の開発環境でProguardを使用する場合は、以下の設定を追加してください。

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    public static final *** NULL;
}

-keepnames class * implements android.os.Parcelable
-keepclassmembers class * implements android.os.Parcelable {
  public static final *** CREATOR;
}

-keep @interface android.support.annotation.Keep
-keep @android.support.annotation.Keep class *
-keepclasseswithmembers class * {
  @android.support.annotation.Keep <fields>;
}
-keepclasseswithmembers class * {
  @android.support.annotation.Keep <methods>;
}

-keep @interface com.google.android.gms.common.annotation.KeepName
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
  @com.google.android.gms.common.annotation.KeepName *;
}

-keep @interface com.google.android.gms.common.util.DynamiteApi
-keep public @com.google.android.gms.common.util.DynamiteApi class * {
  public <fields>;
  public <methods>;
}

-dontwarn android.security.NetworkSecurityPolicy

詳しくはhttps://developers.google.com/android/guides/setup#other をご参照ください。

Google Serviceについてワーニングが出る場合

com.google.gms以下のクラスについてのワーニングが出る場合は、以下の設定を追加することで回避できます。

-dontwarn com.google.gms.**

以上でAndroid SDK設定は完了です。

SDK の使い方

アプリビルド時の注意

Android Studioのデバッグモード実行(MAJIN SDKの接続先のテスト環境ではありません)を行った場合、プッシュが正常に届かない場合があります。リリース時と同様にapkファイルを作成し、検証端末へインストールしてテストを行ってください。

初期化

SDK をアプリ内で利用するには、以下の手順で SDK を初期化します。

初期化場所

Application を継承したクラスの onCreate() 内でSDKを初期化します。

初期化時の設定

GenieeMessaging.initialize に、アプリIDとGenieeMessaging.Configuration を渡して初期化します。

アプリID は MAJIN の管理画面から事前に取得したものです。

@Override
    public void onCreate() {
        super.onCreate();
        // MAJIN SDK を初期化します。
        GenieeMessaging.Configuration configuration = createConfiguration().setSandboxModeEnabled(true);
        GenieeMessaging.initialize(this, "アプリID", configuration);
    }

GenieeMessaging.Configuration の設定

GenieeMessagingは初期化時にGenieeMessaging.Configurationを渡すことで初期化します。

GenieeMessaging.Configurationは渡す前に設定しておきます。

ConfigurationのAPI を参考に設定してください。

GenieeMessaging.Configuration configuration = new GenieeMessaging.Configuration();
configuration.setSandboxModeEnabled(true);
configuration.setNotificationsEnabled(true);
configuration.setNotificationActivity(GameActivity.class);
configuration.setCallback(new GenieeMessaging.Callback() {
    @Override
    public void onRegisterUser() {
    }

    @Override
    public void onRegisterPush() {
    }

    @Override
    public void onReceiveNotification(GenieeMessaging.NotificationEvent notificationEvent, boolean isBackground) {
    }

    @Override
    public void onLaunchFromNotification(GenieeMessaging.NotificationEvent notificationEvent) {
    }
});

GenieeMessaging.Configuration.NotificationStyle notificationStyle = new GenieeMessaging.Configuration.NotificationStyle();
notificationStyle.setNotificationTitle("通知タイトル");
notificationStyle.setNotificationIcon("icon");
notificationStyle.setNotificationChanelId("majin");
notificationStyle.setNotificationChanelName("通知");
notificaitonStyle.setNotificationPopupEnabled(true);
notificaitonStyle.setNotificationOption(NotificationOption.STACK);
notificaitonStyle.setSummaryForStackedNotifications("メッセージが%d件あります");
configuration.setNotificationStyle(notificationStyle);

以下、個別の設定項目の説明です。

接続先の設定

SDKの接続先を設定します。

  • true テスト環境

  • false 本番環境

アプリリリース時に本番サーバーを向くように設定しなおしてください。

configuration.setSandboxModeEnabled(true);

通知許可設定

FCMへの端末のプッシュ通知登録とは別に、MAJINサーバーに通知を許可するかどうかを設定することができます。

SDK初期化時点での通知可否を設定します。

初期化後も GenieeMessagingのメソッドGenieeMessaging.setNotificationsEnabled() で設定を変更することができます。

configuration.setNotificationsEnabled(true);

通知からの起動Activity指定

通知をタップしてアプリを起動する際に開くActivityを指定します。

configuration.setNotificationActivity(GameActivity.class);

コールバック設定

GenieeMessaging.Callback を実装したクラスを渡します。

コールバックのAPI

configuration.setCallback(new GenieeMessaging.Callback() {
    @Override
    public void onRegisterUser() {
    }

    @Override
    public void onRegisterPush() {
    }

    @Override
    public void onReceiveNotification(GenieeMessaging.NotificationEvent notificationEvent, boolean isBackground) {
    }

    @Override
    public void onLaunchFromNotification(GenieeMessaging.NotificationEvent notificationEvent) {
    }
});

通知の表示スタイル設定

以下が、通知の表示スタイル設定です。

下記を指定したものをConfigurationに設定してください。

// notificationStyleを設定済み
configuration.setNotificationStyle(notificationStyle);

通知表示タイトル

通知が通知センターに表示される際のタイトル部分のテキストを指定します。

notificationStyle.setNotificationTitle("通知タイトル");

通知表示アイコン

通知のアイコン画像のパスを指定します。(Androidのプッシュ通知仕様のsmall iconに相当)

notificationStyle.setNotificationIcon("icon.png");

通知表示ポップアップ可否

通知センターへの通知の表示だけでなく、ポップアップダイアログを表示するかどうかを設定します。

notificaitonStyle.setNotificationPopupEnabled(true);

Android 6.0 以上の場合は、事前に以下のようにオーバーレイ表示を許可しておく必要があります。

GenieeMessaging.requestOverlayPermission(this, true);

通知表示スタイル

通知が通知センターに表示される際の表示スタイルを指定します。

  • NotificationOption.NONE - 通知センターに表示せず

  • NotificationOption.MULTIPLE - 通知センターに個別に表示 (デフォルト動作)

  • NotificationOption.OVERWRITE - 新しい通知で上書き表示

  • NotificationOption.STACK - 通知をスタック表示する

notificaitonStyle.setNotificationOption(NotificationOption.STACK);

スタックの表示イメージ

スタック表示

通知サマリテキスト

通知の表示スタイルにスタック表示を選択している場合に、スタックの要約サマリとして表示されるテキストを指定します。

文字列中に %d を含むと、その位置にスタックされた件数が表示されます。

notificaitonStyle.setSummaryForStackedNotifications("メッセージが%d件あります");

コールバック

初期化時に設定した GenieeMessaging.Callback 実装クラスのコールバックが呼ばれます。

onRegisterUser

void onRegisterUser

MAJINサーバーでユーザー登録が完了するとこのコールバックが呼ばれます。

onRegisterPush

void onRegisterPush

端末がFCMに登録された後、登録によって得られた端末レジストレーションIDはSDK内部で自動でMAJINサーバーに送信されます。MAJINサーバーに登録されるとこのコールバックが呼ばれます。

(導入方法 で説明した AndroidManifest.xml の記述がなされていれば、アプリをインストール後に自動でFCMに登録されます。)

onReceiveNotification

void onReceiveNotification(NotificationEvent notificationEvent, boolean isBackground) 

NotificationEventの仕様

アプリが通知を受信した際にこのコールバックが呼ばれます。

(アプリがインストール直後で一度も起動されずFCMに端末が登録されていない状態と、Androidの設定画面から当該アプリを"強制停止"した場合は、通知を受信できません)

アプリはバックグラウンドでは、呼ばれません。

  • Obsolete
    isBackground フォアグラウンドでのみ呼び出されるため常に固定の引数のみ呼ばれます。

onLaunchFromNotification

void onLaunchFromNotification(NotificationEvent notificationEvent) 

NotificationEventの仕様

通知センターに表示されている通知のタップや通知ポップアップダイアログからアプリを起動した際にこのコールバックが呼ばれます。

通知可否設定

FCM へのデバイス登録とは別に、MAJIN のサーバーに対してプッシュ通知を ON にするか OFF にするかを設定できます。

public static void setNotificationsEnabled(boolean enabled) 

SDKのデフォルトでは ON になっています。

以下メソッドでプッシュ通知の設定状態を取得できます。

public static boolean isNotificationsEnabled() 

ローカルプッシュ通知

MAJINサーバーを介さないローカルプッシュを送信することもできます。

ローカルプッシュのAPI

GenieeMessaging.scheduleLocalNotification(getApplicationContext, "message", new Date(), "label");

ログ送信

ページビュー送信

MAJINサーバーにページビューログを送信します。

GenieeMessaging.sendPageView("pageId5");

カスタム属性

MAJINサーバーにカスタム属性を送信します。

CustomAttribute params = new CustomAttribute();
params.setInteger("item": 1);
GenieeMessaging.sendCustom(params);

APIs

GenieeMessaging

initialize

SDKの動作を変更する各種オプションを指定して、SDKを初期化します。

public static void initialize(Application application, String appId, Configuration configuration) 

scheduleLocalNotification

ローカル通知を設定します。

public static void scheduleLocalNotification(Context context, String text, Date dateTime, String label) 

cancelLocalNotification

scheduleLocalNotification で予約した通知を取り消します。

public static void cancelLocalNotification(Context context, String label) 

getRegistrationId

FCMに登録されているデバイストークンを取得します。

public static String getRegistrationId() 

setNotificationsEnabled

MAJINサーバに設定されているプッシュ通知を送信するかどうかの設定を切り替えます。

public static void setNotificationsEnabled(boolean enabled) 

isNotificationsEnabled

MAJINサーバに設定されているプッシュ通知を送信するかどうかの設定を取得します。

public static boolean isNotificationsEnabled() 

sendPageView

MAJINサーバーにページビューのログを送信します。

public static void sendPageView(String pageId) 

sendCustom

MAJINサーバーにカスタム属性を送信します。 属性値は専用のCustomAttribute型のオブジェクトにセットして渡します。

public static void sendCustom(CustomAttribute params) 

value は Protocol Buffers v3 準拠のJSONとします。

requestOverlayPermission

Android6.0以上の端末において、ユーザーに対し通知ポップアップ、リッチページ、広告の表示権限を要求します。 このAPIを呼び出すことで、OSの権限許可設定画面を開きます。

public static void requestOverlayPermission(Activity activity, boolean showDescription) 

hasOverlayPermission

Android6.0以上の端末において、通知ポップアップ、リッチページ、広告の表示権限があるかどうかを返します。

public static boolean hasOverlayPermission(Activity activity) 

GenieeMessaging.Configuration

isSandboxModeEnabled

MAJINの接続先サーバーを取得します。

  • true テスト環境

  • false 本番環境

public boolean isSandboxModeEnabled() 

setSandboxModeEnabled

MAJINの接続先サーバーを設定します。

  • true テスト環境

  • false 本番環境

public Configuration setSandboxModeEnabled(boolean enabled) 

isNotificationEnabled

MAJINサーバーでプッシュ通知がONに設定されているかを取得します。

public boolean isNotificationEnabled() 

setNotificationEnabled

MAJINサーバーのプッシュ通知可否を設定します。

public Configuration setNotificationEnabled(boolean enabled) 

getNotificationStyle

設定されているプッシュ通知の表示設定を取得します。

public NotificationStyle getNotificationStyle() 

setNotificationStyle

プッシュ通知の表示方法を設定します。

public Configuration setNotificationStyle(NotificationStyle notificationStyle) 

setNotificationActivity

プッシュ通知から起動するActivityを指定します。

public static void setNotificationActivity(Activity activity) 

getNotificationLaunchActivity

プッシュ通知から起動するActivityを取得します。

public static String getNotificationLaunchActivity(Context context) 

setCallback

コールバックを設定します。

setCallback(GenieeMessaging.Callback callback)

getCallback

コールバックを取得します。

public GenieeMessaging.Callback getCallback()

GenieeMessaging.Configuration.NotificationOption

NotificationOptionの仕様です

public enum NotificationOption {
    NONE,       // 通知センターに表示せず
    MULTIPLE,   // すべて別々(デフォルト)
    OVERWRITE,  // 上書き
    STACK       // スタック
}

GenieeMessaging.Configuration.NotificationStyle

getNotificationTitle

通知のタイトル文字列を取得します。

public String getNotificationTitle() 

setNotificationTitle

通知のタイトル文字列を設定します。

public Configuration.NotificationStyle setNotificationTitle(String notificationTitle)

getNotificationIcon

通知のアイコン画像指定パスを取得します。

public String getNotificationIcon() 

setNotificationIcon

通知のアイコン画像指定パスを設定します。

public Configuration.NotificationStyle setNotificationIcon(String notificationIcon)

isNotificationPopupEnabled

通知をポップアップダイアログで表示するかの可否を取得します。

public boolean isNotificationPopupEnabled() 

setNotificationPopupEnabled

通知をポップアップダイアログでも表示するか設定します。

public Configuration.NotificationStyle setNotificationPopupEnabled(boolean enabled)

getNotificationOption

NotificationOptionを取得します。

public NotificationOption getNotificationOption() 

setNotificationOption

NotificationOptionを設定します。

public Configuration.NotificationStyle setNotificationOption(NotificationOption notificationOption)

getSummaryForStackedNotifications

通知をスタック表示する際のサマリ文字列を取得します。

public String getSummaryForStackedNotifications() 

setSummaryForStackedNotifications

通知をスタック表示する際のサマリ文字列を設定します。

public Configuration.NotificationStyle setSummaryForStackedNotifications(String summaryForStackedNotifications)

setNotificationChanelId

通知のチャンネルIDを設定します。

public Configuration.NotificationStyle.setNotificationChanelId(String chanelId)

getNotificationChanelId

通知のチャンネルIDを取得します。

public String Configuration.NotificationStyle.getNotificationChanelId()

setNotificationChanelName

通知のチャンネル名を設定します。

public Configuration.NotificationStyle.setNotificationChanelName(String chanelName)

getNotificationChanelName

通知のチャンネル名を取得します。

public String Configuration.NotificationStyle.getNotificationChanelName()

IGNMMessagingCallback

onRegisterUser

MAJINサーバーにユーザー情報が登録された時点で呼び出されます。

public void onRegisterUser() 

onRegisterPush

MAJINサーバーにAPNsデバイストークンが登録された時点で呼び出されます。

public void onRegisterPush() 

onReceiveNotification

アプリがフォアグラウンドにある状態でプッシュ通知を受信した際に呼び出されます。 アプリがバックグラウンドにある場合、このコールバックは呼ばれません。

  • Obsolete
    isBackground フォアグラウンドでのみ呼び出されるため常に固定の引数のみ呼ばれます。
public void onReceiveNotification(GenieeMessaging.NotificationEvent notificationEvent, boolean isBackground) 

onLaunchFromNotification

プッシュ通知からアプリを起動した際に呼び出されます

public void onLaunchFromNotification(GenieeMessaging.NotificationEvent notificationEvent) *)event 

NotificationEvent

String notificationId

リモート通知の場合、プッシュ通知のID

ローカル通知の場合は通知発行時に設定したラベル文字列

String message

プッシュ通知の内容を表すテキスト

JSONObject extra

追加で設定されたデータオブジェクト

boolean isRemoteNotification

プッシュ通知がリモートならYES、ローカルならNO

サンプルアプリ利用方法

  1. プロジェクト名を変更してください。( com.example.sampleapp となっています。)

  2. プロジェクトをFirebaseに登録してください。
    (参考:https://firebase.google.com/docs/android/setup?hl=ja

  3. Firebaseコンソールより google-services.json をダウンロードし、プロジェクトに配置してください。

  4. MAJINコンソールにてサンプルアプリを登録し、appIDを発行してください。

  5. サンプルアプリ内のSampleApplicationでGenieeMessaging.initialize()を呼び出しています。
    "YOUR ID"を4.で取得したappIDに置き換えてください。

  6. プロジェクトを実行します。

MAJIN SDK for iOS

iOS SDK Readme

SDK の概要

MAJIN の以下の機能を iOS アプリから利用するための SDK です。

  1. MAJIN のプッシュ通知機能
    Apple Push Notification services の通知機能を利用します。

  2. MAJIN のログ機能
    起動ログ、ページビュー、カスタム属性を MAJIN に送信します。
    アプリからSDKを通じて送信できるデータは、プッシュ配信のセグメント作成に利用するためのデータとなります。

組み込みに必要なもの

アプリケーションの登録

事前に MAJIN の管理コンソールよりネイティブプッシュアプリケーション一覧の新規作成ボタンからアプリの登録をしてください。

登録時に以下のものが必要となります。

  • iOS BundleID

  • iOSプッシュ証明書 (Development)

  • iOSプッシュ証明書 (Production)

iOSプッシュ証明書の作成につきましては下記をご参考ください。

iOSプッシュ証明書の作成

  1. CSRファイルの作成
  • Macのキーチェーンアクセス.appを使用し、証明書アシスタントでCSRファイルを作成します。

  • 証明書情報の画面で、「ディスクに保存」、「鍵ペア情報を指定」にチェックします。

  1. 開発用証明書(.cer)の作成
  • Developer サイトにログインし、「Certificates, Identifiers & Profiles」のページを開きます。

  • 「Certificates」を選択し、証明書選択画面に進んでください。

  • Developmentの場合「Apple Push Notification service SSL (Sandbox)」にチェックします。

  • Productionの場合「Apple Push Notification service SSL (Sandbox & Production)」にチェックします。

  • 対象のアプリを選択し進みます。

  • CSRファイルのアップロード画面になったら、(1.)で作ったCSRファイルをアップロードします。

  • cerファイルをダウンロードします。

  1. p12ファイルの作成
  • (2.)でダウンロードしたcerファイルをクリックします。

  • キーチェーンアクセスが起動するので、「分類」で自分の証明書を選択します。

  • 読み込まれたcerファイルを選択しp12ファイルへ書き出します。

  • 有効期限が発行日の+1年となっているものです。

  1. pemファイルの作成
  • ターミナルで以下のコマンドを実行してpemファイルを作成します。
$ openssl pkcs12 -in test.p12 -out test.pem -nodes -clcerts
  • 確認のため期限を確認ください。
$ openssl x509 -noout -dates -in test.pem
  • iOSプッシュ証明書としてご利用ください。

MAJIN SDK のダウンロード

以下のリンクからダウンロードしてください。

動作環境

本SDKの組み込みに対応しているiOS OSバージョンは以下の通りです。

iOS 8.0 以上

開発環境

Xcode 8.3 以上

インストール

iOS プロジェクトへの組み込み方法は以下のリンクを参照してください。

SDKインストール方法

SDK の使い方

SDKの使い方

API

API

APNs デバイス登録

Apple Push Notification service (以下、APNs) へのデバイスの登録方法です。

デバイス登録手順

MAJIN のプッシュ通知機能を利用するには、まず APNs に端末を登録する必要があります。

APNs への登録は UIApplication の以下のメソッドを利用します。

- (void)registerUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings

上記を用いて、設定する例です。この例では通知のアラート、バッジ、サウンド全てを設定しています。

UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];

AppDelegate.m に、以下のコールバックを実装します。

  1. 設定の登録成功時

通知のアラート、バッジ、サウンドなどの設定情報の登録の成功時は UIApplication.registerForRemoteNotifications を呼び出します。

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
    [application registerForRemoteNotifications];
}
  1. APNs登録成功時

成功時は deviceToken が取得でき、それを MAJINサーバーに送信します。

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    [GNMMessaging setUpNotifications:deviceToken];
}
  1. APNs登録失敗時
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
}

デバイス登録の状態取得

UIApplication の以下のメソッドで取得できます。

- (BOOL)isRegisteredForRemoteNotifications

通知設定は以下で取得できます。

- (UIUserNotificationSettings *)currentUserNotificationSettings

デバイス登録解除

UIApplication の以下のメソッドで行います。

- (void)unregisterForRemoteNotifications

[[UIApplication sharedApplication] unregisterForRemoteNotifications];

デバイストークンの取得

APNs登録のデバイストークンを GNMMessaging の以下のメソッドで取得できます。

+ (NSString *)getDeviceToken

NSString *devToken = [GNMMessaging getDeviceToken];

iOS SDK のインストール

Xcode プロジェクトの追加

  1. ダウンロードしたファイルを展開し、以下のファイルをXcodeプロジェクトに追加します。
  • MAJIN.framework
  • MAJIN.bundle
  1. 展開したファイルに含まれる以下のフォルダをXcodeプロジェクトに追加します。
  • libs/Reachability
  • libs/Toast

上記を行った後のプロジェクト構成例

  1. Xcode の Build Settings の設定一覧から Framework Search Paths の項目に、先ほどプロジェクトに追加した framework ファイルの置かれているパスを追加します。

  2. Build Settings の設定一覧から Other Linker Flags の項目に -ObjC を追加します。

  3. Capabilities の Push Notifications の項目を ON にします。

SDK の使い方

初期化

SDK をアプリ内で利用するには、以下の手順で SDK を初期化します。

初期化場所

AppDelegate.m にMAJINをインポートします。

@import MAJIN;

AppDelegate.m 内の [application didFinishLaunchingWithOptions:] でSDKの初期化をします。
appId には MAJIN ネイティブプッシュアプリケーション一覧のアプリIDを渡してください。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
       [GNMMessaging initialize:self launchOptions:launchOptions appId:@""];

       return YES;
 }

GenieeMessaging.initialize では、最初の引数にIGNMMessagingCallbackを実装したクラスのインスタンスを渡しています。

AppDelegateIGNMMessagingCallbackを実装していればselfを渡します。

APNs へのデバイス登録

Apple Push Notification Services (APNs) にデバイスを登録します。

APNsへのデバイス登録 をご参考ください。

受信時の処理の記述

プッシュ通知受信時の受信処理を記述します。

以下のコードを AppDelegate.m に追記します。

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    [GNMMessaging processNotifications:userInfo];
}

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
    [GNMMessaging processLocalNotifications:notification];
}

本番環境/デバッグ環境切り替え方法

  • 開発中の実機デバッグは基本的にデバッグ環境となります。
  1. ツールバーの実行ターゲット一覧下部より「Edit Scheme…」を選択します。

  2. 「Run」を選択します。

  3. 「Build Configuration」を「Debug」にします。

  4. ツールバーの「▶︎(Run)」ボタンを押下しデバッグを開始します。

  • テスト用apkファイル作成時の本番環境/デバッグ環境の切り替えは以下の方法で行います。
  1. ツールバーの実行ターゲット一覧下部より「Edit Scheme…」を選択します。

  2. 「Archive」を選択します。

  3. 「Build Configuration」を本番環境の場合(ストアへのアップ含む)は「Release」、デバッグ環境の場合は「Debug」にセットします。

  4. 「Product > Archive」でアーカイブファイルを作成後、「Export…」を選択します。

  5. 本番環境の場合は「AdHoc」、デバッグ環境の場合は「Debug」を選択します。

  6. 以降の設定は本番環境/デバッグ環境の切り替えに影響ありませんので、必要な設定をしてExportを完了します。

  • AppStoreへのアップロードの際は、本番環境用にアーカイブを作成してください。

コールバック

初期化時に設定した IGNMMessagingCallback 実装クラスのコールバックが呼ばれます。

onRegisterUser

- (void)onRegisterUser

MAJINサーバーでユーザー登録が完了するとこのコールバックが呼ばれます。

onRegisterPush

- (void)onRegisterPush

端末デバイストークンがMAJINサーバーに登録されるとこのコールバックが呼ばれます。

onReceiveNotification

- (void)onReceiveNotification:(GNMNotificationEvent *)event

GNMNotificationEventの仕様

アプリがフォアグラウンドで通知を受信した際にこのコールバックが呼ばれます。

onLaunchFromNotification

- (void)onLaunchFromNotification:(GNMNotificationEvent *)event

GNMNotificationEventの仕様

通知センターに表示されている通知のタップからアプリを起動した際にこのコールバックが呼ばれます。

通知可否設定

APNs へのデバイス登録とは別に、MAJIN のサーバーに対してプッシュ通知を ON にするか OFF にするかを設定できます。

[GNMMessaging setNotificationsEnabled:NO;

SDKのデフォルトでは ON になっています。
以下メソッドでプッシュ通知の設定状態を取得できます。

[GNMMessaging isNotificationsEnabled];

ローカルプッシュ通知

MAJINサーバーを介さないローカルプッシュを送信することもできます。

ローカルプッシュのAPI

[GNMMessaging scheduleLocalNotification:@"message" at:[NSDate date] label:@"label"];

ログ送信

ページビュー送信

MAJINサーバーにページビューログを送信します。

[GNMMessaging sendPageView:@"pagename1"];

カスタム属性

MAJINサーバーにカスタム属性を送信します。

GNMCustomAttribute *params = [[GNMCustomAttribute alloc] init];
[params setInteger:1 forKey:@"key"];
[GNMMessaging sendCustom:params];

iOS10 Media Attachment Notification

iOS10以降のデバイスでは画像や動画などを通知センター上で表示したり、プッシュ通知にタイトル・サブタイトルを表示することができます。
マルチメディアデータをプッシュ通知で表示するにはMAJIN管理画面よりメディアURLの入稿を行い、受信側のアプリケーションでハンドリングコードの実装を行う必要があります。
Deployment Targetを 10.0 以上にし、Appleのガイドラインに沿ったNotification Service Extensionの実装を行ってください。
Apple Developer | UNNotificationAttachment

MAJINからのプッシュ通知では下記のマルチメディア形式に対応しています。

  • 音声 ( mp3, wav, aiff, m4a ) 5MB 以内

  • 画像 ( png, jpg, gif ) 10MB 以内

  • 動画 ( mpg, p2v, mpg4, avi ) 50MB 以内

※MAJIN管理画面よりプッシュ通知のコンテンツ登録を行う際、「タイトル」「サブタイトル」「メディアURL」のいずれかの項目の入稿を行うことでアプリケーション側で受信されるaps payloadデータのフォーマットが変更されますのでご注意ください。

従来のフォーマット
{
    "aps": {
        "alert": "プッシュメッセージ"
    },
    "konect": {
        "e": {
            // MAJIN管理画面上で設定した任意のデータJSON領域
        }
    }
}
「タイトル」「サブタイトル」「メディアURL」の入稿を行った際のフォーマット
{
    "aps": {
        "alert": {
            "body": "プッシュメッセージ",
            "title": "タイトル",
            "subtitle": "サブタイトル"
        },
        "mutable-content": 1
    },
    "media-url": "https://xxxxxx.com/a.png",
    "konect": {
        "e": {
            // MAJIN管理画面上で設定した任意のデータJSON領域
        }
    }
}

APIs

GenieeMessaging

initialize:launchOptions:appId:

SDKの動作を変更する各種オプションを指定して、SDKを初期化します。

+ (void)initialize:(NSObject<IGNMMessagingCallback> *)callback
     launchOptions:(NSDictionary *)launchOptions
             appId:(NSString *)appId

setUpNotifications:

MAJINサーバーに端末登録を行います。

+ (void)setUpNotifications:(NSData *)devToken

processLocalNotifications:

ローカルプッシュ通知を処理します。

+ (void)processLocalNotifications:(UILocalNotification *)notification

processNotifications:

リモートプッシュ通知を処理します。

+ (BOOL)processNotifications:(NSDictionary *)userInfo

scheduleLocalNotification:at🏷

ローカル通知を設定します。

+ (UILocalNotification *)scheduleLocalNotification:(NSString *)text at:(NSDate *)dateTime label:(NSString *)label

cancelLocalNotification:

scheduleLocalNotification で予約した通知を取り消します。

+ (void)cancelLocalNotification:(NSString *)label

getDeviceToken

Apple Push Notification Serviceに登録されているデバイストークンを取得します。

+ (NSString *)getDeviceToken

setNotificationsEnabled:

MAJINサーバに設定されているプッシュ通知を送信するかどうかの設定を切り替えます。

+ (void)setNotificationsEnabled:(BOOL)enabled

isNotificationsEnabled

MAJINサーバに設定されているプッシュ通知を送信するかどうかの設定を取得します。

+ (BOOL)isNotificationsEnabled

sendPageView:

MAJINサーバーにページビューのログを送信します。

+ (void)sendPageView:(NSString *)screenName

sendCustom:

MAJINサーバーにカスタム属性を送信します。
属性値は専用のGNMCustomAttribute型のオブジェクトにセットして渡します。

+ (void)sendCustom:(GNMCustomAttribute *)params

params は key, value ともに NSString *とします。
value は Protocol Buffers v3 準拠のJSONとします。

IGNMMessagingCallback

onRegisterUser

MAJINサーバーにユーザー情報が登録された時点で呼び出されます。

- (void)onRegisterUser

onRegisterPush

MAJINサーバーにAPNsデバイストークンが登録された時点で呼び出されます。

- (void)onRegisterPush

onReceiveNotification:

アプリがフォアグラウンドにある状態でプッシュ通知を受信した際に呼び出されます。
アプリがバックグラウンドにある場合、このコールバックは呼ばれません。

- (void)onReceiveNotification:(GNMNotificationEvent *)event

onLaunchFromNotification:

プッシュ通知からアプリを起動した際に呼び出されます。

- (void)onLaunchFromNotification:(GNMNotificationEvent *)event

GNMNotificationEvent

NSString *notificationId

リモート通知の場合、プッシュ通知のID。
ローカル通知の場合は通知発行時に設定したラベル文字列。

NSString *message

プッシュ通知の内容を表すテキスト。

NSDictionary *extra

追加で設定されたデータオブジェクト。

BOOL isRemoteNotification

プッシュ通知がリモートならYES、ローカルならNO。

MAJIN SDK for Unity

Unity SDK Readme

SDK の概要

MAJIN の以下の機能を Unity アプリから利用するための SDK です。

  1. MAJIN のプッシュ通知機能
    AndroidではFirebase Cloud Messaging の通知機能を利用します。
    iOSではApple Push Notification services の通知機能を利用します。

  2. MAJIN のログ機能
    起動ログ、ページビュー、カスタム属性をMAJINに送信します。
    アプリからSDKを通じて送信できるデータは、プッシュ配信のセグメント作成に利用するためのデータとなります。

  3. DMPのログ機能

組み込みに必要なもの

アプリケーションの登録

事前に MAJIN の管理コンソールからアプリの登録をしてください。

詳細はこちら

MAJIN SDK のダウンロード

以下のリンクからダウンロードしてください。

動作環境

本SDKの組み込みに対応しているOSバージョンは以下の通りです。

Android 4.0 以上
iOS 7.0 以上

Unity のバージョンは以下の通りです。

Unity 5.3 以上

開発環境

  • Unity 5.3 以上

  • Xcode 8.3 以上 (iOSの場合)

インストール

Unityプロジェクトへの組み込み方法は以下のリンクを参照してください

SDKインストール方法

SDK の使い方

SDKの使い方

Unity SDK のインストール

Unity SDK のダウンロード

以下からSDKのzipファイルをダウンロードします。

ダウンロードURL[MAJIN_SDK_Unity_v1.0.6.1.zip]

ダウンロードしたzipファイルを展開します。

展開後は以下のファイル構成になっています。

  • MAJINSDK.unitypackage

  • README

Unity プロジェクトへのインポート

Unityプロジェクトにプラグインパッケージをインポートします。インポート先のUnityプロジェクトを開いた状態で MAJINSDK.unitypackage をダブルクリックします。

インポートするファイルの確認が表示されたら全てを選択してインポートします。 (Android向けに利用しない場合、Plugins/Android以下はインポート不要です。またiOS向けに利用しない場合、Plugins/iOS以下は不要です。)

Unityプロジェクトの編集

任意のGameObjectの一つにMAJIN.csをアタッチします。

コールバックを実装するにはMAJINという名前のGameObjectを作りアタッチしてください。

これ以降、Android、iOSごとに手順が異なります。

Unity SDK のインストールとAndroid向け設定

Unity プロジェクトへのインポート

Unity SDKのインストールに記載の手順を実行しているものとします。

Firebase Unity プラグインのインポート

以下のURLから、Firebase SDKのファイルをダウンロードします。

FirebaseのUnityプロジェクト

ダウンロードして展開後に、以下二つのunitypackageをダブルクリックして、Unityプロジェクトにインポートします。

  • FirebaseMessaging.unitypackage

  • FirebaseAuth.unitypackage

次に、Firebaseの依存関係を解消します。Unityエディタのメニューから、以下を選択し実行します。

  • Assets -> Play Services Resolver -> Android Resolver -> Resolve Client Jars

Firebaseの設定

Firebaseの管理画面からFirebaseに登録済みプロジェクトの当該アプリのgoogle-services.jsonファイルをダウンロードします。ダウンロードしたファイルを、UnityプロジェクトのAssetsフォルダ以下に置いてください。

AndroidManifestの編集

既にインポート先のUnityプロジェクトの Assets/Plugins/Android/ 以下に既に AndroidManifest.xml が存在する場合、unitypackageをインポートすると上書きされることに注意してください。

手動で編集する場合、既存のAndroidManifest.xmlに、

<application android:name="jp.co.geniee.sdk.majin.unityplugin.UnityApplication"/>

および

<activity android:name="com.google.firebase.MessagingUnityPlayerActivity" android:label="@string/app_name" android:icon="@drawable/app_icon" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:host="jp.co.geniee.sdk.tracking" android:scheme="myapp" />
        </intent-filter>
        <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    </activity>

の記述と、各種receiver、serviceの記述を追記してください。

<!-- 例 -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

<application android:label="@string/app_name"
             android:name="jp.co.geniee.sdk.majin.unityplugin.UnityApplication"
             android:icon="@drawable/app_icon">

    <activity android:name="com.google.firebase.MessagingUnityPlayerActivity" android:label="@string/app_name" android:icon="@drawable/app_icon" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:host="jp.co.geniee.sdk.tracking" android:scheme="myapp" />
        </intent-filter>
        <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    </activity>
    
    <service android:name="com.google.firebase.messaging.MessageForwardingService" android:exported="false" />
    <receiver android:name="jp.co.geniee.sdk.messaging.LaunchActionReceiver" android:exported="false">
        <intent-filter>
            <action android:name="jp.co.geniee.sdk.messaging.action.launch_from_push" />
            <action android:name="jp.co.geniee.sdk.messaging.action.launch_from_local_push" />
            <action android:name="jp.co.geniee.sdk.messaging.action.launch_cancel" />
        </intent-filter>
    </receiver>
    <receiver android:name="jp.co.geniee.sdk.messaging.LocalNotificationReceiver">
        <intent-filter>
            <action android:name="jp.co.geniee.sdk.push.action.local_send" />
        </intent-filter>
    </receiver>
    <service android:name="jp.co.geniee.sdk.messaging.MaNotificationListenerService" android:exported="false">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>
    <service android:name="jp.co.geniee.sdk.messaging.FcmNotificationTokenService" android:exported="true">
        <intent-filter>
            <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
        </intent-filter>
    </service>
</application>

Applicationの実装

Applicationクラスを独自に実装している場合,jp.co.geniee.sdk.majin.unityplugin.UnityApplicationを継承するよう変更してください。 また、アプリ終了状態にコールバックを実装する場合もUnityApplicationを継承し、Callbackを実装してください。コールバックの設定方法

SDKの設定

Plugins/MAJIN.csを編集します。Awake ()に記載されているコードをプロジェクトに合わせて修正します。

MAJINのプッシュの設定です。

bridgeMessaging = new AndroidJavaObject("jp.co.geniee.sdk.majin.unityplugin.UnityPlugin");

// MAJINの接続先サーバーの設定 true:テスト環境 false:本番環境
bridgeMessaging.Call("setSandboxMode", true);
// 通知のタイトル文字列を設定
bridgeMessaging.Call("setNotificationTitle", "");
// 通知のアイコン画像指定パスを設定
bridgeMessaging.Call("setNotificationIcon", "");
// 通知スタイルを設定 0:表示しない 1:通常表示 2:上書き 3:スタック表示
bridgeMessaging.Call("setNotificationOption", 1); // 0:None, 1:Multiple, 2:Overwrite, 3:Stack
// 通知をスタック表示する際のサマリ文字列を設定
bridgeMessaging.Call("setSummaryForStackedNotifications", "");
// 通知をポップアップダイアログでも表示するかを設定
bridgeMessaging.Call("setNotificationPopupEnabled", false);

// MAJINのアプリIDを設定します。上記設定の最後に記述します。
bridgeMessaging.Call("initialize", ""); // appId

DMPの設定です。DMPを利用しない場合は、Awake中のbridgeTrackerの記述をコメントアウトします。

bridgeTracker = new AndroidJavaObject("jp.co.geniee.sdk.majin.unityplugin.UnityTrackerPlugin");
// コンバージョン計測で必要なURLスキーム
bridgeTracker.Call("setLocationAfterCVTracking", ""); // URL schema
// アプリ一覧情報の収集を許可するか
bridgeTracker.Call("setInstalledAppsCollectionEnabled", false);
// トラッキングIDの設定と初期化
bridgeTracker.Call("initialize", ""); // trackingId

SDKの利用

SDKの利用を参照

UnityプロジェクトのAndroid向けビルド

Unityエディタのメニューから、File -> Build Settings を選択し、Build Settings 画面を開きます。Build Settings 画面で、PlatformからAndroidを選択し、ビルドします。

Unity SDK のインストールとiOS向け設定

Unity プロジェクトへのインポート

Unity SDKのインストールに記載の手順を実行しているものとします。

UnityプロジェクトのiOS向けビルド

Unityエディタのメニューから、File -> Build Settings を選択し、Build Settings 画面を開きます。Build Settings 画面で、PlatformからiOSを選択し、ビルドします。Xcodeプロジェクトが出力されます。

以下、Xcodeプロジェクトでの設定を説明します。Xcodeプロジェクトで後述の設定をし、ビルドするとiOSアプリがビルドされます。

Xcodeプロジェクト出力後のUnityエディタでのUnityプロジェクトの編集は、Xcodeプロジェクトへの再出力をしないと、出力済みのXcodeプロジェクトには反映されません。

Xcode プロジェクトの編集

Xcodeプロジェクト内で、MAJINに関連するファイルの構成は以下のようになっています。

  • Frameworks

    • Plugins
      • iOS
        • MAJIN.bundle
        • MAJIN.framework
  • Librareis

    • Plugins

続けて、次の対応を行います。

  1. Xcode の Build Settings の設定一覧から Framework Search Paths の項目に、MAJIN.frameworkファイルの置かれているパスを追加します。

  2. Build Settings の設定一覧から Other Linker Flags の項目に -ObjC, -all_load を追加します。

  3. アプリIDを設定します。

  4. Capabilities の Push Notifications の項目を ON にします。

SDKの設定

XcodeプロジェクトのLibraries/Plugins/iOS/Libraries以下のファイルを編集します。

MAJINBridge.mmの冒頭にある、以下の定数に値を設定します。

static NSString *_appId = @""; // アプリIDを設定する
static NSString *_trackingId = @""; // トラッキングIDを設定する
static NSString *_appUrl = @""; // URLスキームを設定する

_appIdにMAJINの管理コンソールでアプリを登録した際に発行されるMAJINのアプリIDを設定します。

_trackingId_appUrlはDMPの機能です。使用しない場合、特に値を設定せず、104行目のGNDTrackerの初期化のコードもコメントアウトします。

[GNDTracker initialize:_trackingId];
if (_appUrl.length != 0) {
    [GNDTracker setAppUrl:_appUrl];
}

SDKの利用

SDKの利用を参照

SDK の使い方

利用

UnityプロジェクトからMAJIN SDKを利用します。例としてMAJINSampleAppというスクリプトから利用します。

public class MAJINSampleApp : MonoBehaviour {

    MAJIN majin;

    void Start () {
        majin = GameObject.Find("MAJIN").GetComponent<MAJIN>();
    }
(略)    
}

上記コードのmajinを通して呼べるコードは、MAJIN.csで実装されているpublicメソッドとなります。

APNs へのデバイス登録 (iOSのみ)

以下メソッドでApple Push Notification Services (APNs) にデバイスを登録します。

public void RegisterForRemoteNotifications () 

通知可否設定

Firebase(Android)、APNs(iOS) へのデバイスの登録とは別に、MAJIN のサーバーに対してプッシュ通知を ON にするか OFF にするかを設定できます。SDKのデフォルトでは true になっています。

public void SetNotificationsEnabled (bool enabled) 

以下メソッドでプッシュ通知の設定状態を取得できます。

public bool IsNotificationsEnabled () 

ローカルプッシュ通知

MAJINサーバーを介さないローカルプッシュを送信することもできます。

public void ScheduleLocalNotification (string text, DateTime date, string label)

例。15秒後に"message"というメッセージでローカルプッシュを送信します。

majin.ScheduleLocalNotification("message", DateTime.Now.AddSeconds(15), "label1");

キャンセルは以下を利用します。

public void CancelLocalNotification (string label) 

majin.CancelLocalNotification("label1");

ログ送信

ページビュー送信

MAJINサーバーにページビューログを送信します。

public void SendPageView (string screenName) 

カスタム属性

MAJINサーバーにカスタム属性を送信します。

// MAJIN.CustomAttributeクラス
public void SetInt(string key, int val)
public void SetString(string key, string val)
public void SetBoolean(string key, bool val)
public void SetDate(string key, int year, int month, int day)
public void SetTime(string key, long val)
public void SetStringArray(string key, string[] val)

// MAJINクラス
public void SendCustom(CustomAttribute customAttribute)

MAJIN.CustomAttribute attribute = new MAJIN.CustomAttribute();

// MAJIN.CustomAttributeクラスのインスタンスに任意の値をセットする。
attribute.SetInt("_custom_int", 10);
attribute.SetString("_custom_string", "hogehoge");
attribute.SetBoolean("_custom_bool", true);
attribute.SetDate("_custom_date", 2017, 5, 31);

DateTime datetime = new DateTime(year, month, day, hour, min, second);
TimeSpan diff = datetime - dt;
long time = (long)diff.TotalSeconds;
attribute.SetTime("_custom_time", time);
string[] listValues = new string[] {val1, val2, val3};
attribute.SetStringArray("_custom_string_array", listValues);

// SendCustomで送信する。
majin.SendCustom(attribute);

MAJIN コールバックの設定

MAJIN.cs で実装されているコールバックが呼ばれます。コールバック内で行いたい処理がある場合は、MAJIN.csを編集します。

onRegisterUser

public void onRegisterUser () 

MAJINサーバーでユーザー登録が完了するとこのコールバックが呼ばれます。

onRegisterPush

public void onRegisterPush () 

端末デバイストークンがMAJINサーバーに登録されるとこのコールバックが呼ばれます。

onReceiveNotification

public void onReceiveNotification (string param) 

アプリがフォアグラウンドで通知を受信した際にこのコールバックが呼ばれます。

引数のparamはJSON形式の文字列で、LitJsonなどを使ってパースしてください。

  • notificationId - リモート通知の場合、プッシュ通知のID。ローカル通知の場合は通知発行時に設定したラベル文字列

  • message - プッシュ通知の内容を表すテキスト

  • extra - 追加で設定されたデータオブジェクト

  • isRemoteNotification -プッシュ通知がリモートならtrue、ローカルならfalse

onLaunchFromNotification

public void onLaunchFromNotification (string param) 

通知センターに表示されている通知のタップからアプリを起動した際にこのコールバックが呼ばれます。

引数のparamはJSON形式の文字列で、LitJsonなどを使ってパースしてください。

  • notificationId - リモート通知の場合、プッシュ通知のID。ローカル通知の場合は通知発行時に設定したラベル文字列

  • message - プッシュ通知の内容を表すテキスト

  • extra - 追加で設定されたデータオブジェクト

  • isRemoteNotification -プッシュ通知がリモートならtrue、ローカルならfalse

DMP の機能

任意イベント送信

下記メソッドを使用します。

public void PushEvent (string eventName) 
public void PushEventWithAttributes (string eventName, Dictionary<string, string> attributes) 

アプリ内課金の送信 (iOSのみ)

下記メソッドを使用します。

public void PushPurchase (string productId, float price, string currency) 

majin.PushPurchase("jp.co.geniee.sample.item.item1", 150, "yen");

Generated by aglio on 19 Jan 2022