- Registriert
- 19.10.14
- Beiträge
- 48
Hallo
Für meine kleine App plane ich eine Ergänzung in Form von Local Notification. Den Code für die Notification habe ich schon geschrieben und er funktioniert soweit auch:
Jetzt möchte ich beim Start der App, dass überprüft wird, ob Notification erlaubt ist. Wenn nicht, dass dann in Form einer AlertView danach gefragt wird. Ein Beispiel habe ich schon gefunden, funktioniert leider nicht:
PS: Die App ist für iOS 8.0 und höher ausgerichtet
Für meine kleine App plane ich eine Ergänzung in Form von Local Notification. Den Code für die Notification habe ich schon geschrieben und er funktioniert soweit auch:
Code:
// Create new UILocalNotification object.
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
// Set the date and time of the notification.
localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:10];
// Set the message body of the notification.
localNotification.alertBody = @"It works, Yeeeeh";
//Sound
localNotification.soundName = @"sound.mp3";
// Set the time zone of the notification.
localNotification.timeZone = [NSTimeZone defaultTimeZone];
// Perform the notification.
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
Jetzt möchte ich beim Start der App, dass überprüft wird, ob Notification erlaubt ist. Wenn nicht, dass dann in Form einer AlertView danach gefragt wird. Ein Beispiel habe ich schon gefunden, funktioniert leider nicht:
Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]) {
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeSound categories:nil]];
}
return YES;
}
PS: Die App ist für iOS 8.0 und höher ausgerichtet