プッシュ通知のサポート
Apple Push Notification Service (APNs) をSingular SDKと統合することで、プッシュ通知によるユーザーインタラクションを追跡し、リエンゲージメントキャンペーンやコンバージョンを正確に測定することができます。
以下の実装ガイドラインに従って、通知データが正しくSingular SDKに渡され、適切なアトリビューションが行われるようにしてください。
プッシュ通知を追跡する理由プッシュ通知はリエンゲージメントを促進しますが、トラッキングには正しい統合が必要です。Singularは、通知を受け取ったユーザーが適切にアトリビューションされるようにし、マーケティングキャンペーンとエンゲージメント戦略を最適化します。
実装ガイド
プッシュ通知の登録
odedeUNUserNotificationCenter を使用して、プッシュ通知を受信する許可をユーザーに要求し、アプリを APN に登録します。
import UserNotifications
// Set the current instance as the delegate for UNUserNotificationCenter
UNUserNotificationCenter.current().delegate = self
// Define the notification authorization options (alert, badge, sound)
let pushAuthOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
// Request notification authorization from the user
UNUserNotificationCenter.current().requestAuthorization(options: pushAuthOptions) { granted, error in
// If an error occurs during authorization, print the error description
if let error = error {
print("registerForPushNotifications : failure - \(error.localizedDescription)")
}
// If the user granted permission, register for remote notifications
if granted {
// Ensure registration is done on the main thread
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
}
}
- (void)registerForPushNotifications:(UIApplication *)application {
// Set delegate to self
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
// Define the push notification options
UNAuthorizationOptions pushAuthOptions = UNAuthorizationOptionAlert |
UNAuthorizationOptionBadge |
UNAuthorizationOptionSound;
// Request push notification authorization
[[UNUserNotificationCenter currentNotificationCenter]
requestAuthorizationWithOptions:pushAuthOptions
completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (error) {
NSLog(@"registerForPushNotifications : failure - %@", error.localizedDescription);
}
if (granted) {
dispatch_async(dispatch_get_main_queue(), ^{
[application registerForRemoteNotifications];
});
}
}];
}
ベストプラクティス:理想的には、オプトイン率を向上させるためにユーザーに価値を示した後です。
通知レスポンスの処理
ユーザーがプッシュ通知をタップしたときの通知レスポンスを処理し、トラッキングのためにペイロードデータをSingularに転送します。
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
// Extract the notification payload
let userInfo = response.notification.request.content.userInfo
// Pass the notification data to Singular for tracking
Singular.handlePushNotification(userInfo)
// Call the completion handler to indicate processing is complete
completionHandler()
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)(void))completionHandler {
// Extract the push notification payload (user info)
NSDictionary *userInfo = response.notification.request.content.userInfo;
// Log the userInfo dictionary for debugging purposes
NSLog(@"didReceiveNotificationResponse userInfo = %@", userInfo);
// Pass the notification data to Singular for tracking
[Singular handlePushNotification:userInfo];
// Call the completion handler to indicate processing is complete
completionHandler();
}
ベストプラクティス:完了が遅れると、システムの警告やスロットルが発生する可能性があります。
プッシュペイロード用にSDKを設定する
SDK設定にプッシュ通知ペイロードセレクタを追加して、Singularリンクが通知データ構造のどこにあるかを指定します。
func getConfig() -> SingularConfig? {
guard let config = SingularConfig(apiKey: "SDK_KEY", andSecret: "SDK_SECRET") else {
return nil
}
// Configure push notification link paths
config.pushNotificationLinkPath = [
["sng_link"],
["rootObj", "nestedObj", "anotherNested", "singularLink"]
]
return config
}
// Start the Singular SDK with the configuration
if let config = getConfig() {
Singular.start(config)
}
- (SingularConfig *)getConfig {
SingularConfig *config = [[SingularConfig alloc] initWithApiKey:@"SDK_KEY"
andSecret:@"SDK_SECRET"];
// Configure push notification link paths
config.pushNotificationLinkPath = @[
@[@"sng_link"],
@[@"rootObj", @"nestedObj", @"anotherNested", @"singularLink"]
];
return config;
}
// Start the Singular SDK with the configuration
SingularConfig *config = [self getConfig];
[Singular start:config];
セレクタ構成:
-
シンプルなキー:ペイロードのトップレベルキーに
["sng_link"]。 - ネストされたキー:ネストされたJSON構造をトラバースするには、odede["rootObj", "nestedObj", "key"]を使用してください。
- 複数のパス:複数のセレクタ配列を定義して、Singularリンクの異なる可能性のある場所をチェックする。
検証ガイド
セッション開始時のペイロードの検証
開始セッションAPIコールを検査することで、プッシュ通知リンクがSingularに正しく渡されていることを確認します。
Singular SDKは、ユーザーが通知をタップすると、開始セッションリクエストのsingular_link パラメータの下にプッシュ通知ペイロードを含めます。
セッション開始リクエストの例:
https://skan.singular.net:443/api/v1/start?
dnt=-1
&update_time=0
&singular_link=https://sl.sng.link/Cclbu/2a7n?_dl=com.singular.app&_smtype=3
&i=com.singular.SwiftScene
&sdk=Singular/12.7.1
&p=iOS
&v=18.2.1
代替検証:Singular SDKコンソールを使用して、プッシュ通知のトラッキングを確認します。ディープリンクURLフィールドをチェックして、トラッキングリンクが正しくキャプチャされていることを確認します。
高度な構成
ESPドメイン設定
SingularリンクをEメールサービスプロバイダ(ESP)またはその他のサードパーティのドメインでラップする場合は、外部ドメインを設定します。
func getConfig() -> SingularConfig? {
guard let config = SingularConfig(apiKey: "SDK_KEY", andSecret: "SDK_SECRET") else {
return nil
}
// Configure ESP domains for wrapped links
config.espDomains = ["sl.esp.link", "custom.domain.com"]
return config
}
- (SingularConfig *)getConfig {
SingularConfig *config = [[SingularConfig alloc] initWithApiKey:@"SDK_KEY"
andSecret:@"SDK_SECRET"];
// Configure ESP domains for wrapped links
config.espDomains = @[@"sl.esp.link", @"custom.domain.com"];
return config;
}
セキュリティ上の注意:デフォルトでは、Singularリンク管理ページで事前に定義されたsng.linkドメインのみが許可されます。ラップリンクを使用する場合は、ESPドメインを明示的に設定します。
ダイナミックディープリンクルーティング
動的なリダイレクトオーバーライドで1つのSingularトラッキングリンクを設定することで、1つの通知から複数のディープリンク先を実装できます。
使用例複数のアクションオプションを持つニュース速報
-
最新ニュースを読む:
newsapp://article?id=12345 -
トレンドトピック
newsapp://trending -
スポーツ
newsapp://sports
複数のトラッキングリンクを作成する代わりに、1つのSingularリンクを使用し、ユーザーの選択に基づいて動的にリダイレクトを上書きします。実装の詳細については、Singular トラッキングリンクでリダイレクトを上書きするを参照してください。
重要な考慮事項
実装上の注意
-
コールバックハンドラはありません:
singularLinksHandlerと異なり、プッシュ通知機能はペイロードコールバックを提供しません。独自のディープリンクロジックを実装して、ユーザーをアプリ内の特定のコンテンツに誘導してください。 -
アトリビューションフロー:ユーザーが通知をタップすると、Singularはペイロードを取得し、
Singular.start()によってトリガーされるセッション開始イベントに含めます。バックエンドはこのデータを処理して、プッシュ通知のタッチポイントに属性を付け、リエンゲージメント追跡を登録します。 -
ドメインの制限:デフォルトでは、[Manage Links(リンクの管理)]ページにあるSingularリンクドメイン(
sng.link)のみが許可されています。espDomainsを使用して、ラップリンク用の ESP ドメインを明示的に設定します。
成功しました:これらのステップに従うことで、あなたのアプリはSingularでプッシュ通知のインタラクションをトラッキングし、キャンペーンパフォーマンスのインサイトを改善し、正確なリエンゲージメントアトリビューションを保証します。