【问题标题】:How to send a push notification for a fixed hour?如何在固定时间发送推送通知?
【发布时间】:2015-07-01 10:35:07
【问题描述】:

我是新的 IOS 开发人员,以前从未使用过推送通知或本地。

用户需要设置一个小时,用于接收推送通知。 我的申请需要做什么?

我的应用程序,每天为每个在小时前设置推送通知的用户发送。推送通知始终相同。

谁能帮帮我?我该怎么做?

【问题讨论】:

标签: ios iphone push-notification apple-push-notifications


【解决方案1】:

设置本地通知的参考链接:

http://www.appcoda.com/ios-programming-local-notification-tutorial/

http://www.icodeblog.com/2010/07/29/iphone-programming-tutorial-local-notifications/

//在第一个链接的代码中替换Appdelegate.m中的以下方法

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.

//-- Set Notification
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
    [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
    [[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}

// Handle launching from a notification
UILocalNotification *locationNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (locationNotification) {
    // Set icon badge number to zero
    application.applicationIconBadgeNumber = 0;
}

return YES;
}

【讨论】:

  • 没用。我下载了两个源代码,什么都没有。没有人返回本地通知
  • 以上源码中没有添加注册本地通知代码。所以我为 is 和 iOS8 本地通知添加了几行。
【解决方案2】:

您可以为本地通知执行此操作

NSDate *date = self.datePicker.date;

UILocalNotification *note = [[UILocalNotification alloc] init];
note.alertBody = @"Say Hello!";
note.fireDate = date;

[[UIApplication sharedApplication] scheduleLocalNotification:note];

您还可以使用 parse.com 的框架进行远程通知

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-02-07
    • 1970-01-01
    • 2021-10-14
    • 1970-01-01
    • 1970-01-01
    • 2018-02-17
    • 1970-01-01
    相关资源
    最近更新 更多