是否可以将应用设置为在指定时间从自身发送通知?也许将他们排在队列中?到目前为止,我必须经过一个推送通知服务器,当我在每个星期二早上发送消息时,这似乎已被淘汰。另外,这叫什么(以便我可以更好地在网络上进行研究)
最佳答案
您可以像这样安排通知:
- (void)scheduleNotification
{
//Cancel all previous Local Notifications
[[UIApplication sharedApplication] cancelAllLocalNotifications];
//Set new Local Notifications
Class cls = NSClassFromString(@"UILocalNotification");
if (cls != nil)
{
UILocalNotification *notif = [[cls alloc] init];
//3 days
notif.fireDate = [NSDate dateWithTimeInterval:60.0f*60.0f*24.0f*3.0f sinceDate:[NSDate date]];
notif.timeZone = [NSTimeZone defaultTimeZone];
notif.alertBody = @"Come Back Again! Lets blast All Zombie!";
notif.alertAction = @"PLAY";
notif.soundName = UILocalNotificationDefaultSoundName;
notif.applicationIconBadgeNumber = 1;
[[UIApplication sharedApplication] scheduleLocalNotification:notif];
}
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[application registerForRemoteNotificationTypes:
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound];
[self scheduleNotification];
..
}
关于ios - 预先通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17789180/