diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..70554b6 Binary files /dev/null and b/.DS_Store differ diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/LocalNotificationBase.xcodeproj/project.pbxproj b/LocalNotificationBase.xcodeproj/project.pbxproj old mode 100644 new mode 100755 index dd7afac..1c12d12 --- a/LocalNotificationBase.xcodeproj/project.pbxproj +++ b/LocalNotificationBase.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 2280B31D22B2C4680008A5DB /* BronzeTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2280B31C22B2C4680008A5DB /* BronzeTableViewController.swift */; }; AA6671C922B1292D00824252 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA6671C822B1292D00824252 /* AppDelegate.swift */; }; AA6671CB22B1292D00824252 /* BaseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA6671CA22B1292D00824252 /* BaseViewController.swift */; }; AA6671CE22B1292D00824252 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AA6671CC22B1292D00824252 /* Main.storyboard */; }; @@ -15,6 +16,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 2280B31C22B2C4680008A5DB /* BronzeTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BronzeTableViewController.swift; sourceTree = ""; }; AA6671C522B1292D00824252 /* LocalNotificationBase.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LocalNotificationBase.app; sourceTree = BUILT_PRODUCTS_DIR; }; AA6671C822B1292D00824252 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; AA6671CA22B1292D00824252 /* BaseViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseViewController.swift; sourceTree = ""; }; @@ -35,6 +37,15 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 2280B31E22B2C4700008A5DB /* Views */ = { + isa = PBXGroup; + children = ( + AA6671CA22B1292D00824252 /* BaseViewController.swift */, + 2280B31C22B2C4680008A5DB /* BronzeTableViewController.swift */, + ); + path = Views; + sourceTree = ""; + }; AA6671BC22B1292D00824252 = { isa = PBXGroup; children = ( @@ -54,8 +65,8 @@ AA6671C722B1292D00824252 /* LocalNotificationBase */ = { isa = PBXGroup; children = ( + 2280B31E22B2C4700008A5DB /* Views */, AA6671C822B1292D00824252 /* AppDelegate.swift */, - AA6671CA22B1292D00824252 /* BaseViewController.swift */, AA6671CC22B1292D00824252 /* Main.storyboard */, AA6671CF22B1293000824252 /* Assets.xcassets */, AA6671D122B1293000824252 /* LaunchScreen.storyboard */, @@ -136,6 +147,7 @@ buildActionMask = 2147483647; files = ( AA6671CB22B1292D00824252 /* BaseViewController.swift in Sources */, + 2280B31D22B2C4680008A5DB /* BronzeTableViewController.swift in Sources */, AA6671C922B1292D00824252 /* AppDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -283,7 +295,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = GT48V5L69E; + DEVELOPMENT_TEAM = 4LXC4A87QZ; INFOPLIST_FILE = LocalNotificationBase/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -301,7 +313,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = GT48V5L69E; + DEVELOPMENT_TEAM = 4LXC4A87QZ; INFOPLIST_FILE = LocalNotificationBase/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", diff --git a/LocalNotificationBase.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/LocalNotificationBase.xcodeproj/project.xcworkspace/contents.xcworkspacedata old mode 100644 new mode 100755 diff --git a/LocalNotificationBase.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/LocalNotificationBase.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist old mode 100644 new mode 100755 diff --git a/LocalNotificationBase/AppDelegate.swift b/LocalNotificationBase/AppDelegate.swift old mode 100644 new mode 100755 index 07da379..ad34ac9 --- a/LocalNotificationBase/AppDelegate.swift +++ b/LocalNotificationBase/AppDelegate.swift @@ -44,6 +44,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { 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. + UIApplication.shared.applicationIconBadgeNumber = 0 } func applicationWillTerminate(_ application: UIApplication) { diff --git a/LocalNotificationBase/Assets.xcassets/AppIcon.appiconset/Contents.json b/LocalNotificationBase/Assets.xcassets/AppIcon.appiconset/Contents.json old mode 100644 new mode 100755 diff --git a/LocalNotificationBase/Assets.xcassets/Contents.json b/LocalNotificationBase/Assets.xcassets/Contents.json old mode 100644 new mode 100755 diff --git a/LocalNotificationBase/Base.lproj/LaunchScreen.storyboard b/LocalNotificationBase/Base.lproj/LaunchScreen.storyboard old mode 100644 new mode 100755 diff --git a/LocalNotificationBase/Base.lproj/Main.storyboard b/LocalNotificationBase/Base.lproj/Main.storyboard old mode 100644 new mode 100755 index 0d2afb5..f4b4218 --- a/LocalNotificationBase/Base.lproj/Main.storyboard +++ b/LocalNotificationBase/Base.lproj/Main.storyboard @@ -1,5 +1,5 @@ - + @@ -10,7 +10,7 @@ - + @@ -31,9 +31,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LocalNotificationBase/Info.plist b/LocalNotificationBase/Info.plist old mode 100644 new mode 100755 diff --git a/LocalNotificationBase/BaseViewController.swift b/LocalNotificationBase/Views/BaseViewController.swift old mode 100644 new mode 100755 similarity index 100% rename from LocalNotificationBase/BaseViewController.swift rename to LocalNotificationBase/Views/BaseViewController.swift diff --git a/LocalNotificationBase/Views/BronzeTableViewCell.swift b/LocalNotificationBase/Views/BronzeTableViewCell.swift new file mode 100644 index 0000000..e08aa09 --- /dev/null +++ b/LocalNotificationBase/Views/BronzeTableViewCell.swift @@ -0,0 +1,24 @@ +// +// BronzeTableViewCell.swift +// LocalNotificationBase +// +// Created by Victor Falcetta do Nascimento on 13/06/19. +// Copyright © 2019 Bruno Omella Mainieri. All rights reserved. +// + +import UIKit + +class BronzeTableViewCell: UITableViewCell { + + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } + + override func setSelected(_ selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + + // Configure the view for the selected state + } + +} diff --git a/LocalNotificationBase/Views/BronzeTableViewController.swift b/LocalNotificationBase/Views/BronzeTableViewController.swift new file mode 100644 index 0000000..ac912d1 --- /dev/null +++ b/LocalNotificationBase/Views/BronzeTableViewController.swift @@ -0,0 +1,106 @@ +// +// BronzeTableViewController.swift +// LocalNotificationBase +// +// Created by Victor Falcetta do Nascimento on 13/06/19. +// Copyright © 2019 Bruno Omella Mainieri. All rights reserved. +// + +import UIKit +import UserNotifications + +class BronzeTableViewController: UITableViewController, UIPickerViewDelegate, UIPickerViewDataSource { + + + @IBOutlet weak var fieldTitulo: UITextField! + @IBOutlet weak var fieldCorpo: UITextField! + @IBOutlet weak var pickerTempoSeg: UIPickerView! + @IBOutlet weak var switchSom: UISwitch! + @IBOutlet weak var switchBadge: UISwitch! + + var pickerDadosSeg: [String] = [String]() + + + override func viewDidLoad() { + super.viewDidLoad() + + self.pickerTempoSeg.delegate = self + self.pickerTempoSeg.dataSource = self + + pickerDadosSeg = ["0","1","2","3","4","5","6","7","8","9"] + + + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + } + + func numberOfComponents(in pickerView: UIPickerView) -> Int { + return 1 + } + + func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { + return pickerDadosSeg.count + } + + func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { + return pickerDadosSeg[row] + } + + + + @IBAction func botaoEnviar(_ sender: Any) { + let contentudo = UNMutableNotificationContent() + + if let tituloFieldText = self.fieldTitulo.text{ + contentudo.title = NSString.localizedUserNotificationString(forKey: tituloFieldText, arguments: nil) + } + + if let corpoFieldText = self.fieldCorpo.text{ + contentudo.title = NSString.localizedUserNotificationString(forKey: corpoFieldText, arguments: nil) + } + + + + if self.switchSom.isOn { + contentudo.sound = UNNotificationSound.default + } + + let triggerino = UNTimeIntervalNotificationTrigger(timeInterval: TimeInterval(pickerTempoSeg.selectedRow(inComponent: 0)) , repeats: false) + + let request = UNNotificationRequest(identifier: "BronzeOmella", content: contentudo, trigger: triggerino) + + if self.switchBadge.isOn{ + contentudo.badge = 1 + } + + let bronzeNotificationCenter = UNUserNotificationCenter.current() + bronzeNotificationCenter.getNotificationSettings{ (settings) in + if settings.authorizationStatus == .authorized{ + let center = UNUserNotificationCenter.current() + center.add(request) { (error : Error?) in + if let error = error { + print(error.localizedDescription) + } + } + }else{ + print("Impossível mandar notificação - permissão negada") + } + } + } +} + + + // MARK: - Table view data source + +// override func numberOfSections(in tableView: UITableView) -> Int { +// // #warning Incomplete implementation, return the number of sections +// return 0 +// } +// +// override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { +// // #warning Incomplete implementation, return the number of rows +// return 0 +// } + diff --git a/README.md b/README.md old mode 100644 new mode 100755