特定时间的Fire PushNotifications - Swift

时间:2017-04-01 01:12:11

标签: ios swift apple-push-notifications uipickerview

您好,我想知道是否有办法在特定日期通过用户的批准显示推送通知。我目前有一个推送通知的切换,当调用此切换时,它应该显示一个选择器视图,以便用户希望这些通知何时到来。例如,用户可以选择每周,每天,每月(这将是非常好的)或每年的通知。此外,让用户能够选择具体的日子将是一个很好的接触。我不知道如何做到这一点。在此过程中,我将不胜感激任何指导或帮助。

背景: 我正在为我的高中报纸制作一个应用程序,并想提醒用户查看该应用程序。每个月的第一天通知用户会很好,因为我们的学校会在每个月的第一天发布新问题。

以下是我的应用现在的screenshot

这是我当前的AppDelegate.swift代码以供参考:

//
//  AppDelegate.swift
//  TheGunnOracleApp
//
//  Created by Rajat Khare on 11/22/16.
//  Copyright © 2016 RDKhare. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {




        if(!UserDefaults.standard.bool(forKey: "HasLaunchedOnce"))
        {

            UserDefaults.standard.set(true, forKey: "HasLaunchedOnce")
            UserDefaults.standard.synchronize()

        }
        else{

            let storyboard = UIStoryboard(name: "Main", bundle: nil)

            self.window!.rootViewController = storyboard.instantiateViewController(withIdentifier: "StartAfterFirst")

            self.window?.makeKeyAndVisible()

        }



        if Reachability.checkIntenetRechable() == false {



            let alert = UIAlertController(title: "No Internet Connection", message: "The Internet connection appears to be offline. Please connect to Wi-Fi or use Cellular Data to continue", preferredStyle: UIAlertControllerStyle.alert)

            alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))

            self.window?.rootViewController?.present(alert, animated: true, completion: nil)

        }


        return true
    }





    func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {





        return true
    }

    func applicationWillResignActive(_ application: UIApplication) {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
    }

    func applicationDidEnterBackground(_ application: UIApplication) {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }

    func applicationWillEnterForeground(_ application: UIApplication) {
        // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }

    func applicationWillTerminate(_ application: UIApplication) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }


    func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {

        if shortcutItem.type == "com.rdkhare.Home"{

            let storyboard = UIStoryboard(name: "Main", bundle: nil)
            let frontNavigationController = storyboard.instantiateViewController(withIdentifier: "VCHome")
            let rearNavigationController = storyboard.instantiateViewController(withIdentifier: "menuVC")
            let mainRevealController : SWRevealViewController = SWRevealViewController(rearViewController: rearNavigationController, frontViewController: frontNavigationController)

            self.window?.rootViewController? = mainRevealController
//            let homeVC = sb.instantiateViewController(withIdentifier: "homePage1") as! WebViewHome
//            let root = UIApplication.shared.keyWindow?.rootViewController
//            let navController = UINavigationController(rootViewController: homeVC)
//            root?.present(navController, animated: true, completion: {
//                completionHandler(true)


//            })

    }




    }


}

0 个答案:

没有答案