ExtensionDelegate를 내 UNUserNotificationCenterDelegate로 만들고 올바르게 할당했습니다.watchOS 3 - userNotificationCenter에서해야 할 일은 무엇입니까? willPresentNotification : withCompletionHandler : 실제로 알림을 표시 하시겠습니까?
- (void) userNotificationCenter:(UNUserNotificationCenter*)center
willPresentNotification:(UNNotification*)notification
withCompletionHandler:(void(^)(UNNotificationPresentationOptions))completionHandler
{
NSLog(@"ExtensionDelegate: willPresent!");
completionHandler(UNNotificationPresentationOptionAlert);
}
문제는 아무 변화가 없다는 것입니다 : 내 watchOS 3 응용 프로그램은 다음과 같이 내가 방법을 구현 한
userNotificationCenter:willPresentNotification:withCompletionHandler:
트리거 알림 요청을 추가 할 수 있습니다. 내가 watchOS 3.1을 실행하는 장치에서 Xcode 8.2에서 디버깅 중이며이 위임 메서드가 트리거되었지만 중단 점에 도달 할 수 있지만 경고가 표시되지 않습니다.
UNMutableNotificationContent* content = [[UNMutableNotificationContent alloc] init];
content.title = notificationType;
content.subtitle = [NSString stringWithFormat:@"Subtitle: %@", notificationType];
content.body = alertTitle;
content.badge = @1;
content.sound = [UNNotificationSound defaultSound];
content.launchImageName = @"LaunchImage";
content.userInfo = @{
@"notificationType" : notificationType,
@"count" : @(count)
};
content.attachments = @[];
content.categoryIdentifier = notificationType;
notificationType 다음과 같이 내 응용 프로그램의 실행에 설정된는 NSString입니다 : 불행하게도
// Register custom notification types
UNNotificationCategory* cat1 = [UNNotificationCategory categoryWithIdentifier:@"Category1"
actions:@[dismissAction]
intentIdentifiers:@[]
options:UNNotificationCategoryOptionNone];
UNNotificationCategory* cat2 = [UNNotificationCategory categoryWithIdentifier:@"Category2"
actions:@[dismissAction, yesAction]
intentIdentifiers:@[]
options:UNNotificationCategoryOptionNone];
NSSet* categorySet = [NSSet setWithArray:@[cat1, cat2]];
[center setNotificationCategories:categorySet];
알림 요청이있을 때, willPresentNotification이 왕래의 completionHandler를 다음과 같이 내 컨텐츠입니다 호출되고, 그 다음 앱은 포 그라운드에서 계속 실행됩니다. 화면에 알림 경고가 표시되지 않습니다. 시계 모드의 드래그 다운 도크에는 나타나지 않습니다. 화면 상에 또는 그곳에 또는 풀다운 선창에 나타나게하려면 무엇을해야합니까?
다음은 앱 상단에서 볼 수있는 화면의 예입니다. 또는 화면 상단에서 플러시 상단으로 이동하고 그 아래에서 앱이 실행됩니다.
알림을 보낼 권한을 요청 했습니까? 시계 프로그래밍 가이드 : 시스템에서 알림을 게시하거나 앱 알림을위한 사운드를 재생하기 전에 Watch 앱 또는 iOS 앱이 사용자와 상호 작용할 수있는 권한을 요청해야합니다. 공유 UNUserNotificationCenter 오브젝트의 requestAuthorizationWithOptions : completionHandler : 메소드를 호출하여이를 수행하십시오. – lostAtSeaJoshua
아니요, 시작시 권한을 요청하고 시작시 가져 왔습니다. 나는 단지 실제적인 경고 그 자체를 보낼 필요가있다. 표시되는 시계 화면 상단의 배너와 마찬가지로 사라집니다. WKInterfaceView (또는 무엇이든)로 만들어야합니까? – Cindeselia
내게 불분명 한 점은 위임자의 willPresentNotification이 호출 될 때 실제로 알림을 표시하기 위해 무엇을해야 하는가? UI를 변경하는 것과 같은 화려한 사용자 정의 동작은 필요 없습니다. 시계 아이콘 상단에있는 작은 아이콘 (일부 디자이너는 '팬케이크'또는 '축배'라고 함)을 앱 아이콘과 한 줄의 텍스트. "목표 달성!" 또는 무엇이든. 이것은 예를 들어 시계면의 스 와이프 다운 메뉴에서 볼 수있는 알림 유형입니다. 나는 그것을 보여줄 필요가있다. 처음부터 코드를 작성해야합니까? 우리가 무료로 얻을 수없는 것 같아. – Cindeselia