概要
AppBank Fello は AppBank が提供するスマホ向けユーザ獲得ツールです。
iOS・Androidアプリのアクティブユーザー数が増える「AppBank Fello」
主な機能として
- プッシュ通知
- メッセンジャー
- 広告配信
があります。
SDK が配布されており、導入も比較的簡単です。
iOS 向けには Obj-C で作成されたライブラリが提供されています。
本稿では Swift から利用する方法を解説します。
基本的には公式で解説されているものを読み替えるだけで OK です。
プッシュ通知機能を組み込む | AppBank Fello
実装
1. ライブラリをプロジェクトに組み込む
ダウンロードした FelloPush.bundle
および FelloPush.framework
をドラッグアンドドロップでプロジェクトに組み込みます
2. Build Settings に FelloPush を追加する
Build Settings > Linking > Other Linker Flags に以下を追記します。
-framework FelloPush
3. Build Phases に ライブラリを追加する
Build Phases > Link Binary With Libraries に以下 3 つのライブラリを追加します。
- libsqlite3.0.dylib
- StoreKit.framework
- AdSupport.framework
4. Bridging Header を作成する
Objective-C で作成されたライブラリを swift から読み込むために Bridging Header ファイルを作成します。
好きな場所に Fello-Bridging-Header.h
を作成してください。
Fello-Bridging-Header.h
//
// Fello-Bridging-Header.h
//
#import <FelloPush/IKonectNotificationsCallback.h>
#import <FelloPush/KonectNotificationsAPI.h>
5. AppDelegate.swift を修正する
AppDelegate ファイルを修正します。
AppDelegate.swift
// IKonectNotificationsCallback を追加
class AppDelegate: UIResponder, UIApplicationDelegate, IKonectNotificationsCallback {
AppDelegate.swift
// リモートプッシュの設定(Fello SDK を利用する)
KonectNotificationsAPI.initialize(self, launchOptions:launchOptions, appId:"YOUR-APP-ID")
その他もろもろ
AppDelegate.swift
// デバイストークンを受信した際の処理
func application(aplication: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken devToken: NSData) {
println("デバイストークンを受信した際の処理")
KonectNotificationsAPI.setupNotifications(devToken)
}
// プッシュ通知を受信した際の処理
func application(aplication: UIApplication, didReceiveRemoteNotification userInfo: NSDictionary) {
println("プッシュ通知を受信した際の処理")
KonectNotificationsAPI.processNotifications(userInfo)
}
// このメソッドで、プッシュ通知からの起動後の処理を行うことが出来る
func onLaunchFromMessage(messageId: String!, message: String!, extra: [NSObject : AnyObject]!) {
println("ここでextraの中身にひもづいたインセンティブの付与などを行うことが出来ます")
}