iOS新機能更新サマリー

iOS 14新機能

iOS 14の新機能には主にAPP Clip、クリップボード、プライバシー保護などの新機能が含まれていますが、通知関連の新機能はありません。

iOS 13新機能

iOS 13の新機能には主にダークモード、Swift UIなどの新機能が含まれていますが、通知関連の新機能はありません。

iOS 12新機能

グループ化プッシュ

iOS 12では、同じタイプの通知が1つの通知グループに統合されます。ユーザーは通知グループをクリックすることで、グループ内のすべての通知を展開できます。

通知のグループ化には2つの方法が使用されます:自動グループ化とスレッド識別子(Thread identifier)。自動グループ化の場合、開発者は特に何もする必要はなく、システムがAppのbundleIdに基づいてプッシュをグループ化します。より細かく通知をグループ化する必要がある場合は、スレッド識別子を使用する必要があります。

ユーザーはグループの設定(自動、アプリごと、オフ)を行うことができます。

Thread identifier属性はiOS 10から存在していますが、実際にグループ化を実装したのはiOS 12からです。

// この通知リクエストに関連するスレッドまたは会話の一意の識別子。通知を視覚的にグループ化するために使用されます。 @property (NS_NONATOMIC_IOSONLY, copy) NSString *threadIdentifier __TVOS_PROHIBITED;
              
              // この通知リクエストに関連するスレッドまたは会話の一意の識別子。通知を視覚的にグループ化するために使用されます。
@property (NS_NONATOMIC_IOSONLY, copy) NSString *threadIdentifier __TVOS_PROHIBITED;

            
このコードブロックはフローティングウィンドウ内に表示されます

サマリー形式の設定

通知が自動的にグループ化された後、下部にメッセージのサマリーが表示されます。デフォルトの形式は「さらにn件の通知」です。この形式はカスタマイズ可能です。

最初の方法:UNNotificationCategoryを介した形式のカスタマイズ

+ (instancetype)categoryWithIdentifier:(NSString *)identifier actions:(NSArray<UNNotificationAction *> *)actions intentIdentifiers:(NSArray<NSString *> *)intentIdentifiers hiddenPreviewsBodyPlaceholder:(nullable NSString *)hiddenPreviewsBodyPlaceholder categorySummaryFormat:(nullable NSString *)categorySummaryFormat options:(UNNotificationCategoryOptions)options __IOS_AVAILABLE(12.0) __WATCHOS_PROHIBITED;
              
              + (instancetype)categoryWithIdentifier:(NSString *)identifier
                               actions:(NSArray<UNNotificationAction *> *)actions
                     intentIdentifiers:(NSArray<NSString *> *)intentIdentifiers
         hiddenPreviewsBodyPlaceholder:(nullable NSString *)hiddenPreviewsBodyPlaceholder
                 categorySummaryFormat:(nullable NSString *)categorySummaryFormat
                               options:(UNNotificationCategoryOptions)options __IOS_AVAILABLE(12.0) __WATCHOS_PROHIBITED;

            
このコードブロックはフローティングウィンドウ内に表示されます

2番目の方法はUNNotificationContentを介したカスタマイズです。

/// この通知のサマリーに挿入される引数。 @property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *summaryArgument __IOS_AVAILABLE(12.0) __WATCHOS_PROHIBITED __TVOS_PROHIBITED; /// サマリー内の項目がサマリーで表される数を示す数値。 /// 例えば、ポッドキャストアプリが1つのショーの3つの新しいエピソードに対して1つの通知を送信する場合、 /// 引数はショーの名前で、カウントは3にする必要があります。 /// デフォルトは1で、0にすることはできません。 @property (NS_NONATOMIC_IOSONLY, readonly, assign) NSUInteger summaryArgumentCount __IOS_AVAILABLE(12.0) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
              
              /// この通知のサマリーに挿入される引数。
@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *summaryArgument __IOS_AVAILABLE(12.0) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;

/// サマリー内の項目がサマリーで表される数を示す数値。
/// 例えば、ポッドキャストアプリが1つのショーの3つの新しいエピソードに対して1つの通知を送信する場合、
/// 引数はショーの名前で、カウントは3にする必要があります。
/// デフォルトは1で、0にすることはできません。
@property (NS_NONATOMIC_IOSONLY, readonly, assign) NSUInteger summaryArgumentCount __IOS_AVAILABLE(12.0) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;

            
このコードブロックはフローティングウィンドウ内に表示されます

通知管理

Appleは、メッセージに「管理」ボタンを追加し、左にスワイプすると表示されるようになりました。

一時的な許可

一時的な許可の主な体现は、プッシュメッセージに2つのボタンが表示され、ユーザーに積極的に選択させることです。

警告通知

家族の安全、健康、公共の安全などに関する通知です。この種のメッセージはユーザーが必ずアクションを実行する必要があります。簡単なシナリオとして、自宅にカメラを設置していて、外出中に自宅に人が入った場合、カメラから通知が送信されることがあります。このタイプの通知には特別な証明書が必要です。

iOS 10新機能

説明

iOS 10では、通知周りに多くの新機能が追加されました。詳細については、engagelabの公式ブログを参照してください。

iOS 10 Service Extension

説明

iOS 10で追加されたService Extension 公式の図解は以下の通りです これは、APNsがデバイスに到達する前に、Extensionサービスによって処理されることを意味し、ユーザーは独自の設定を行うことができ、APNsに多様性を追加することができます。

使用方法

Service Extensionの使用は簡単です。まず、Service Extensionサービスを作成する必要があります。以下の図を参照してください。

ここで注意すべき点がいくつかあります

  • Service ExtensionのBundle Identifierは、Main Target(自分のApp Target)のBundle Identifierと同じにすることはできません。同じにすると、重複したBundeIDエラーが発生します。
  • Service ExtensionのBundle Identifierは、Main Targetの名前空間内にある必要があります。例えば、Main TargetのBundleIDがio.mtpush.xxxの場合、Service ExtensionのBundleIDはio.mtpush.xxx.yyyのような形式にする必要があります。そうしないと、エラーが発生する可能性があります。

これでService Extensionが作成され、正常に使用できるようになりましたが、まだ何も処理を行っていません。プロジェクトを確認すると、2つのメソッドを含むクラスが作成されています。

  • didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent *contentToDeliver))contentHandler
  • serviceExtensionTimeWillExpire

最初のメソッドの公式の説明を見てみましょう:変更された通知コンテンツを使用してcontentHandlerを呼び出し、配信します。サービスの期限が切れる前にハンドラーが呼び出されない場合、変更されていない通知が配信されます。 簡単に説明すると、このメソッドはAPNsが到着したときに呼び出され、プッシュされたコンテンツを処理した後、contentHandlerを使用して処理を行うことができます。ただし、時間が長すぎると、APNsはそのまま表示されます。 つまり、このメソッドで通知を処理し、ユーザーに合わせてカスタマイズすることができます。 一方、2番目の方法は、最初の方法の救済策です。2番目の方法は期限が切れる前にコールバックされ、APNsメッセージに緊急の処理を行うことができます。

iOS 9統合

iOS 9の変更がSDKに影響する部分:

  • bitCodeエンコーディング形式が追加されました。SDKがbitCodeをサポートしていない場合、ユーザーは統合時にbitCodeオプションを有効にすることができません。
    • 症状:ユーザーがSDKを統合した後、コンパイルに失敗し、エラーログにbitCodeエラー情報が含まれています。
  • デフォルトの接続はhttpsです。リクエストがhttpの場合、plistを手動で構成してhttpサービスをサポートする必要があります。現在、私たちのサーバーのリクエストはすべてhttpサービスに送信されます。
    • 症状:ユーザーがSDKを統合した後、MTPushに関連するすべてのhttpサービスで接続エラーまたは接続タイムアウトが発生する場合、これが原因かもしれません。

bitCodeの解決策

  • MTPush iOS SDK v1.8.7以降では、iOS 9の新機能であるbitCodeのサポートが追加されています。

Httpsの解決策

MTPush 2.0.0以降では、このステップは必要ありません。

  • 現在のプロジェクトのInfo.plistに、NSAppTransportSecurityタイプのDictionaryを積極的に追加する必要があります。
  • NSAppTransportSecurityの下にBooleanタイプのNSAllowsArbitraryLoadsを追加し、YESに設定します。

iOS 9 UIUserNotificationActionBehaviorTextInput

サポートバージョン

v1.8.0バージョンから利用可能です。

  1. iOS 9におけるプッシュの最大の変更は、プッシュのCategoryタイプの修正です。元のプッシュカテゴリに基づいて、テキストアクションタイプが追加されました。このパラメータは、通知ショートカットテキストを介して入力された項目を登録するために使用されます。
  2. このカテゴリは一連のUIUserNotificationCategoryで構成されています。各UIUserNotificationCategoryオブジェクトでは、一連のUIMutableUserNotificationActionタイプのパラメータを追加して、通知バーの項目を増やすことができます。現在、iOS 9では、元のUIMutableUserNotificationActionタイプにテキスト入力タイプ(UIUserNotificationActionBehaviorTextInput)が追加されており、behavior(iOS 9でのみ使用可能なプロパティ)を介して設定されます。
  3. iOS 9では、ボタンクリックのイベントを処理するために2つの新しいコールバックメソッドが使用されます:
- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullableNSString *)identifier forLocalNotification:(UILocalNotification *)notification withResponseInfo:(NSDictionary *)responseInfo completionHandler:(void(^)())completionHandler NS_AVAILABLE_IOS(9_0) - (void)application:(UIApplication *)application handleActionWithIdentifier:(nullableNSString *)identifier forRemoteNotification:(NSDictionary *)userInfo withResponseInfo:(NSDictionary *)responseInfo completionHandler:(void(^)())completionHandler NS_AVAILABLE_IOS(9_0)
              
              - (void)application:(UIApplication *)application handleActionWithIdentifier:(nullableNSString *)identifier forLocalNotification:(UILocalNotification *)notification withResponseInfo:(NSDictionary *)responseInfo completionHandler:(void(^)())completionHandler NS_AVAILABLE_IOS(9_0)

- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullableNSString *)identifier forRemoteNotification:(NSDictionary *)userInfo withResponseInfo:(NSDictionary *)responseInfo completionHandler:(void(^)())completionHandler NS_AVAILABLE_IOS(9_0)

            
このコードブロックはフローティングウィンドウ内に表示されます

説明:

  • ActionがUIUserNotificationActionBehaviorTextInputの場合、responseInfoのUIUserNotificationActionResponseTypedTextKeyを介して入力されたテキストを取得する必要があります。UIUserNotificationTextInputActionButtonTitleKeyを介してクリックされたボタンのタイプを取得します。
  • ActionがUIUserNotificationActionBehaviorDefaultの場合、responseInfoはnilであり、identifierを介してどのボタンがクリックされたかを区別して処理を行います。

クライアント設定

クイックリプライ機能を備えた通知を設定する

# ifdef __IPHONE_9_0 UIMutableUserNotificationAction *replyAction = [[UIMutableUserNotificationAction alloc]init]; replyAction.title = @"返信"; replyAction.identifier = @"comment-reply"; replyAction.activationMode = UIUserNotificationActivationModeBackground; replyAction.behavior = UIUserNotificationActionBehaviorTextInput; UIMutableUserNotificationCategory *category = [[UIMutableUserNotificationCategory alloc]init]; category.identifier = @"reply"; [category setActions:@[replyAction] forContext:UIUserNotificationActionContextDefault]; # endif
              
              # ifdef __IPHONE_9_0 
 UIMutableUserNotificationAction *replyAction = [[UIMutableUserNotificationAction alloc]init];
 replyAction.title = @"返信";
 replyAction.identifier = @"comment-reply";
 replyAction.activationMode = UIUserNotificationActivationModeBackground;
 replyAction.behavior = UIUserNotificationActionBehaviorTextInput;
  
 UIMutableUserNotificationCategory *category = [[UIMutableUserNotificationCategory alloc]init];
 category.identifier = @"reply";
 [category setActions:@[replyAction] forContext:UIUserNotificationActionContextDefault];
# endif

            
このコードブロックはフローティングウィンドウ内に表示されます

コールバック関数を使用する

- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo withResponseInfo:(NSDictionary *)responseInfo completionHandler:(void(^)())completionHandler NS_AVAILABLE_IOS(9_0) {if ([identifier isEqualToString:@"comment-reply"]) {NSString *response = responseInfo[UIUserNotificationActionResponseTypedTextKey]; // 入力されたテキストを処理 } completionHandler();}
              
              - (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo withResponseInfo:(NSDictionary *)responseInfo completionHandler:(void(^)())completionHandler NS_AVAILABLE_IOS(9_0) {if ([identifier isEqualToString:@"comment-reply"]) {NSString *response = responseInfo[UIUserNotificationActionResponseTypedTextKey];
 // 入力されたテキストを処理
 }
 completionHandler();}

            
このコードブロックはフローティングウィンドウ内に表示されます

サーバー側設定

サーバーのコンテンツ形式:apsにcategoryフィールドを追加し、このフィールドがクライアントのUIMutableUserNotificationCategoryのidentifierと一致すると、設定されたアクションとボタンが表示されます。

payload example: {"aps":{"alert":"example", "sound":"default", "badge": 1, "category":"reply"}}
              
              payload example:
{"aps":{"alert":"example", "sound":"default", "badge": 1, "category":"reply"}}

            
このコードブロックはフローティングウィンドウ内に表示されます

iOS 8 UILocalNotification

iOS 8のUILocalNotificationには、region、regionTriggersOnce、categoryの3つのパラメータが追加されました。

  • region:ユーザーが地理的な場所に入ったり出たりしたときに通知をトリガーするように制御します。この機能を使用するには、ユーザーがCoreLocationの「使用中」権限を持っている必要があります。
  • regionTriggersOnce(BOOL):YESの場合、通知は一度だけトリガーされ、NOの場合、入るたびまたは出るたびにトリガーされます。
  • category: ローカル通知が+ [UIUserNotificationSettings settingsForUserNotificationTypes:userNotificationActionSettings:]を介して登録されている場合、このcategoryを介して登録された通知のカテゴリを取得できます。

クライアント設定

UILocalNotificationの使用

// ローカル通知を設定 CLLocationCoordinate2D coordinate2D; coordinate2D.latitude = 100.0; coordinate2D.longitude = 100.0; CLRegion *currentRegion = [[CLCircularRegion alloc] initWithCenter:coordinate2D radius:CLLocationDistanceMax identifier:@"test"]; [APService setLocalNotification:[NSDate dateWithTimeIntervalSinceNow:120] alertBody:@"test ios8 notification" badge:0 alertAction:@"取消" identifierKey:@"1" userInfo:nil soundName:nil region:currentRegion regionTriggersOnce:YES category:@"test"];
              
              // ローカル通知を設定
  CLLocationCoordinate2D coordinate2D;
  coordinate2D.latitude = 100.0;
  coordinate2D.longitude = 100.0;
  CLRegion *currentRegion =
      [[CLCircularRegion alloc] initWithCenter:coordinate2D
                                        radius:CLLocationDistanceMax
                                    identifier:@"test"];
 
  [APService setLocalNotification:[NSDate dateWithTimeIntervalSinceNow:120]
                        alertBody:@"test ios8 notification"
                            badge:0
                      alertAction:@"取消"
                    identifierKey:@"1"
                         userInfo:nil
                        soundName:nil
                           region:currentRegion
               regionTriggersOnce:YES
                         category:@"test"];

            
このコードブロックはフローティングウィンドウ内に表示されます

iOS 8 UIUserNotificationSettings

サポートバージョン

v1.8.0バージョンから利用可能です。

クライアント設定

UIUserNotificationCategoryの使用

if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {NSMutableSet *categories = [NSMutableSet set]; UIMutableUserNotificationCategory *category = [[UIMutableUserNotificationCategory alloc] init]; category.identifier = @"identifier"; UIMutableUserNotificationAction *action = [[UIMutableUserNotificationAction alloc] init]; action.identifier = @"test2"; action.title = @"test"; action.activationMode = UIUserNotificationActivationModeBackground; action.authenticationRequired = YES; //YESの場合は赤で表示され、NOの場合は青で表示されます action.destructive = NO; NSArray *actions = @[action]; [category setActions:actions forContext:UIUserNotificationActionContextMinimal]; [categories addObject:category]; }
              
              if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {NSMutableSet *categories = [NSMutableSet set];
 
 UIMutableUserNotificationCategory *category = [[UIMutableUserNotificationCategory alloc] init];
 
 category.identifier = @"identifier";
 
 UIMutableUserNotificationAction *action = [[UIMutableUserNotificationAction alloc] init];
 
 action.identifier = @"test2";
 
 action.title = @"test";
 
 action.activationMode = UIUserNotificationActivationModeBackground;
 
 action.authenticationRequired = YES;
 
 //YESの場合は赤で表示され、NOの場合は青で表示されます
 action.destructive = NO;
 
 NSArray *actions = @[action];
 
 [category setActions:actions forContext:UIUserNotificationActionContextMinimal];
 
 [categories addObject:category];
}

            
このコードブロックはフローティングウィンドウ内に表示されます

UIUserNotificationTypeの使用

if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {[APService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:categories]; }else{[APService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil]; }
              
              if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {[APService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)                      categories:categories];
}else{[APService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)                      categories:nil];
}

            
このコードブロックはフローティングウィンドウ内に表示されます

コールバック関数の使用

// リモート通知からアクションを選択することでアプリがアクティブ化されたときに呼び出されます。 // nilのアクション識別子はデフォルトのアクションを示します。 // アクションの処理が完了したらすぐにcompletion handlerを呼び出す必要があります。 - (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)())completionHandler {}
              
              // リモート通知からアクションを選択することでアプリがアクティブ化されたときに呼び出されます。
// nilのアクション識別子はデフォルトのアクションを示します。
// アクションの処理が完了したらすぐにcompletion handlerを呼び出す必要があります。
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo
  completionHandler:(void (^)())completionHandler {}

            
このコードブロックはフローティングウィンドウ内に表示されます

サーバー側設定

サーバーのコンテンツ形式:apsにcategoryフィールドを追加し、このフィールドがクライアントのUIMutableUserNotificationCategoryのidentifierと一致すると、設定されたアクションとボタンが表示されます。

payload example: {"aps":{"alert":"example", "sound":"default", "badge": 1, "category":"identifier"}}
              
              payload example:
{"aps":{"alert":"example", "sound":"default", "badge": 1, "category":"identifier"}}

            
このコードブロックはフローティングウィンドウ内に表示されます

iOS 7バックグラウンドリモート通知

iOS 7におけるプッシュの最大の変更は、アプリが通知を受信した後にバックグラウンドでコードを実行できるようになったことです。これを使用して、サーバーから更新を取得することができます。アプリケーションシナリオ:(マルチメディア)チャット、Emailの更新、通知に基づくサブスクリプションコンテンツの同期など、ユーザーエクスペリエンスを向上させます。

リモート通知と以前のバージョンの違いについては、以下の2つのApple公式の画像を参照してください。

content-available:1のみを含み、バッジ、サウンド、メッセージコンテンツのパラメータが指定されていない場合、ユーザーに迷惑をかけずにコンテンツの更新などの操作を実行できます。これを「サイレントリモート通知」と呼びます。

クライアント設定

リモート通知を有効にする

XcodeのアプリのCapabilitiesを変更し、リモート通知を有効にする必要があります。以下の画像を参照してください:

通知ハンドラーを変更する

Backgroud Modes -> Remote notificationsに登録されている場合、通知ハンドラーは次の関数に切り替わり、ここでバックグラウンドプッシュコードも呼び出されます。

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler;
              
              - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler;

            
このコードブロックはフローティングウィンドウ内に表示されます

サーバープッシュ設定

バックグラウンドで実行するための必須パラメータとして、プッシュメッセージにcontent-available:1を含めます。このフィールドが含まれていない場合、iOS 7以前の通常のプッシュメッセージと同じです。

Webポータルを使用したプッシュ

オプション設定で、関連するパラメータを選択します。

APIを使用したプッシュ

Push APIのiosでcontent-available":trueフィールドを追加するだけです(以降でサポート)

制限事項と注意事項

  • 「サイレントリモート通知」は、Appleの制限内で頻度制御が指定されていないものです。したがって、すべての「サイレントリモート通知」が意図したようにクライアント側のトリガー関数に到達するわけではありません。
  • 「バックグラウンド」でアプリケーションに提供される実行ウィンドウは限られています。 largerファイルをダウンロードする必要がある場合は、AppleのNSURLSessionの紹介を参照してください。
  • バックグラウンドリモート通知には、クライアントがバックグラウンドまたはサスペンド状態である必要があります。ユーザーがApp Switcherを介してバックグラウンドからアプリケーションを強制終了した場合、アプリケーションはバックグラウンドコードを処理するために起動しません。

詳細な説明については、Appleの公式iOS開発ドキュメントを参照してください。

icon
お問い合わせ