Apple Watchプログラミングの作法 Extensionアプリ/Objective-C対応

通知表示(Notification) - アプリメインで結果を判別する

Icon comment count 0
Icon stock count 0

13.10 アプリメインで結果を判別する

通知画面でボタンが押されるとアプリメイン画面が起動し、押されたボタンの識別子がアプリメイン画面のhandleActionWithIdentifier:forRemoteNotification:に渡されます。

識別子はペイロードデータ内のidentifierで指定した文字列です。

InterfaceController.m(アプリメイン画面)
@interface InterfaceController()
@property (weak, nonatomic) IBOutlet WKInterfaceLabel *responseMessage;
@end
@implementation InterfaceController
- (void)awakeWithContext:(id)context {
  [super awakeWithContext:context];
}
- (void)willActivate {
  [super willActivate];
}
- (void)didDeactivate {
  [super didDeactivate];
}
- (void)handleActionWithIdentifier:(NSString *)identifier 
          forRemoteNotification:(UILocalNotification *)localNotification {
  
  // 料理の希望について処理する
  if([identifier isEqualToString:@"vote.izakayaButtonAction"]) {
    [_responseMessage setText:@"居酒屋を選びました"];
  }
  if([identifier isEqualToString:@"vote.chineseButtonAction"]) {
    [_resp

コメント

    コメントはありません