0

私のアプリでは、アラーム機能を使用しています。正常に動作していますが、シミュレーターでテストしているときに、ポップアップ ボックスでアラームが通知されます。実際のデバイスでは、ポップアップ ボックスではなくステータス バーに通知として表示されます。

実機でポップアップボックスを探しています。ここで何が間違っているのかわかりませんか?

このコードをアラームに使用しています

[[UIApplication sharedApplication] cancelAllLocalNotifications];

UILocalNotification *localNotification = [[UILocalNotification alloc] init];

localNotification.fireDate = date;

localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.alertBody = alarmMessage;
localNotification.alertAction = NSLocalizedString(@"View", nil);
localNotification.repeatInterval = NSDayCalendarUnit;

/* Here we set notification sound and badge on the app's icon "-1"
 means that number indicator on the badge will be decreased by one
 - so there will be no badge on the icon */


NSString *ringtonename = [lblRingToneName text];
NSString *extension = @".caf";

NSString  *ringtone = [[NSString alloc]initWithFormat:@"%@%@", ringtonename, extension];

localNotification.soundName = ringtone;
localNotification.applicationIconBadgeNumber = -1;

[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];     

助けてくれてありがとう

4

2 に答える 2

1

デバイスがロックされている場合、通知はポップ ボックスとして表示されます。アプリが実行されている場合、通知はステータス バーに表示されます。コードについては何もありません。

于 2012-09-03T08:56:49.867 に答える
1

When a UILocalNotification is fired, there are 3 possibilities:

  • Your app is running in the background or is closed: your local notification will appear according to the settings the user defined: it may appear as a banner, as a UIAlertView, or not to appear at all.

  • Your app is running in the foreground: You can receive, in your AppDelegate class, any local notification with the following method:

    - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification

  • The device is locked: the device will show an alert in the locked screen (or won't if the user defined so)

于 2012-09-03T09:02:38.773 に答える