このコードを AppDelegate.m の下に配置して、ローカル通知をテストしようとしています:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
NSDate *alertTime = [[NSDate date]dateByAddingTimeInterval:5];
UIApplication* thisApp = [UIApplication sharedApplication];
UILocalNotification* notify = [[UILocalNotification alloc] init];
if (notify){
notify.fireDate = alertTime;
notify.timeZone = [NSTimeZone defaultTimeZone];
notify.repeatInterval = 0;
notify.alertBody = @"This is notification";
[thisApp scheduleLocalNotification:notify];
}
}
しかし、他のアプリケーションと同じように音は聞こえません。独自のサウンドを提供する必要がありますか?通知に Apple ネイティブ サウンドを使用できませんか?
通知の「タイトルテキスト」を設定する方法は?私が見ているのはnotify.alertBody = @"This is notification";
、タイトルに何も生成しないだけで、タイトルとして「通知」であるためです。
ありがとうございました...