Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Empty file modified LICENSE
100644 → 100755
Empty file.
4 changes: 4 additions & 0 deletions LocalNotificationBase.xcodeproj/project.pbxproj
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
6DA9F0A222B2C08100EE6415 /* BronzeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DA9F0A122B2C08100EE6415 /* BronzeViewController.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 */; };
Expand All @@ -15,6 +16,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
6DA9F0A122B2C08100EE6415 /* BronzeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BronzeViewController.swift; sourceTree = "<group>"; };
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 = "<group>"; };
AA6671CA22B1292D00824252 /* BaseViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -56,6 +58,7 @@
children = (
AA6671C822B1292D00824252 /* AppDelegate.swift */,
AA6671CA22B1292D00824252 /* BaseViewController.swift */,
6DA9F0A122B2C08100EE6415 /* BronzeViewController.swift */,
AA6671CC22B1292D00824252 /* Main.storyboard */,
AA6671CF22B1293000824252 /* Assets.xcassets */,
AA6671D122B1293000824252 /* LaunchScreen.storyboard */,
Expand Down Expand Up @@ -135,6 +138,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
6DA9F0A222B2C08100EE6415 /* BronzeViewController.swift in Sources */,
AA6671CB22B1292D00824252 /* BaseViewController.swift in Sources */,
AA6671C922B1292D00824252 /* AppDelegate.swift in Sources */,
);
Expand Down
Empty file.
Empty file.
1 change: 1 addition & 0 deletions LocalNotificationBase/AppDelegate.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

func applicationDidBecomeActive(_ application: UIApplication) {
UIApplication.shared.applicationIconBadgeNumber = 0
// 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.
}

Expand Down
Empty file.
Empty file modified LocalNotificationBase/Assets.xcassets/Contents.json
100644 → 100755
Empty file.
Empty file modified LocalNotificationBase/Base.lproj/LaunchScreen.storyboard
100644 → 100755
Empty file.
119 changes: 117 additions & 2 deletions LocalNotificationBase/Base.lproj/Main.storyboard
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="eAA-zS-1m4">
<device id="retina6_1" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
Expand All @@ -10,7 +10,120 @@
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Base View Controller-->
<!--Bronze-->
<scene sceneID="kmh-GC-xbx">
<objects>
<viewController id="CN1-Pk-ffU" customClass="BronzeViewController" customModule="LocalNotificationBase" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="ImU-Xz-Tu1">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="2HD-eM-J4d">
<rect key="frame" x="20" y="111" width="374" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<textField opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="AnA-Iy-ULu">
<rect key="frame" x="20" y="207" width="374" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Titulo:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mQf-rf-nKq">
<rect key="frame" x="20" y="82" width="48" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Corpo:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BSY-n2-9Zd">
<rect key="frame" x="20" y="178" width="52" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Me avise em:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="XuP-El-ti2">
<rect key="frame" x="20" y="275" width="101" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Som:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="A8n-dl-sIH">
<rect key="frame" x="20" y="529" width="40" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Badge:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="x26-0J-xiQ">
<rect key="frame" x="20" y="577" width="54" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="NYd-rH-ULN">
<rect key="frame" x="346" y="524" width="49" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</switch>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="hHL-Di-qq3">
<rect key="frame" x="346" y="572" width="49" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</switch>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="kCE-oZ-cOS">
<rect key="frame" x="169" y="698" width="77" height="58"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="25"/>
<state key="normal" title="Enviar"/>
<connections>
<action selector="enviarButton:" destination="CN1-Pk-ffU" eventType="touchUpInside" id="FPv-OX-uIY"/>
</connections>
</button>
<pickerView contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="oXh-8z-nLF">
<rect key="frame" x="0.0" y="300" width="414" height="216"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
</pickerView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<viewLayoutGuide key="safeArea" id="csR-I3-ROa"/>
</view>
<tabBarItem key="tabBarItem" title="Bronze" id="hEg-Qz-0sA"/>
<connections>
<outlet property="badgeSwitchOutlet" destination="hHL-Di-qq3" id="95X-Lo-fUR"/>
<outlet property="corpoField" destination="AnA-Iy-ULu" id="zLm-n4-wvL"/>
<outlet property="pickerSegundos" destination="oXh-8z-nLF" id="nKj-ze-2ye"/>
<outlet property="somSwitchOutlet" destination="NYd-rH-ULN" id="zyb-VY-hO2"/>
<outlet property="tituloField" destination="2HD-eM-J4d" id="HuA-l7-i00"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="xqr-dP-fkF" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-652.17391304347836" y="125.89285714285714"/>
</scene>
<!--Tab Bar Controller-->
<scene sceneID="4VH-Ar-t4O">
<objects>
<tabBarController id="eAA-zS-1m4" sceneMemberID="viewController">
<tabBar key="tabBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="K1T-1I-RtZ">
<rect key="frame" x="0.0" y="0.0" width="414" height="49"/>
<autoresizingMask key="autoresizingMask"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</tabBar>
<connections>
<segue destination="BYZ-38-t0r" kind="relationship" relationship="viewControllers" id="oCg-a8-ymA"/>
<segue destination="CN1-Pk-ffU" kind="relationship" relationship="viewControllers" id="L62-Pw-CZN"/>
</connections>
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="lPg-fM-QTw" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-1541" y="-234"/>
</scene>
<!--Base-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="BaseViewController" customModule="LocalNotificationBase" customModuleProvider="target" sceneMemberID="viewController">
Expand All @@ -31,9 +144,11 @@
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
<tabBarItem key="tabBarItem" title="Base" id="dPV-JP-3Wp"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-652" y="-510"/>
</scene>
</scenes>
</document>
1 change: 1 addition & 0 deletions LocalNotificationBase/BaseViewController.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class BaseViewController: UIViewController {
content.body = NSString.localizedUserNotificationString(forKey: "Você se lembrou", arguments: nil)
content.sound = UNNotificationSound.default


let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false)

let request = UNNotificationRequest(identifier: "5seconds", content: content, trigger: trigger)
Expand Down
135 changes: 135 additions & 0 deletions LocalNotificationBase/BronzeViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
//
// BronzeViewController.swift
// LocalNotificationBase
//
// Created by Luiz Henrique Monteiro de Carvalho on 13/06/19.
// Copyright © 2019 Bruno Omella Mainieri. All rights reserved.
//

import UIKit
import UserNotifications
class BronzeViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {

func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}

func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return pickerData.count
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return pickerData[row]
}




@IBOutlet weak var tituloField: UITextField!
@IBOutlet weak var corpoField: UITextField!


@IBOutlet weak var pickerSegundos: UIPickerView!
var pickerData: [String] = [String]()

@IBOutlet weak var somSwitchOutlet: UISwitch!
@IBOutlet weak var badgeSwitchOutlet: UISwitch!



override func viewDidLoad() {
super.viewDidLoad()

self.pickerSegundos.delegate = self
self.pickerSegundos.dataSource = self

pickerData = ["0","1","2","3","4","5","6","7","8","9","10"]

// Do any additional setup after loading the view.
}




@IBAction func enviarButton(_ sender: Any) {

let notificationCenterBronze = UNUserNotificationCenter.current()
let contentBronze = UNMutableNotificationContent()

if let tituloFieldText = self.tituloField.text{
contentBronze.title = NSString.localizedUserNotificationString(forKey: tituloFieldText, arguments: nil)
}

if let corpoFieldText = self.corpoField.text{
contentBronze.body = NSString.localizedUserNotificationString(forKey: corpoFieldText, arguments: nil)
}



if self.somSwitchOutlet.isOn{
contentBronze.sound = UNNotificationSound.default
}else{
contentBronze.sound = .none
}

if self.badgeSwitchOutlet.isOn{
contentBronze.badge = 1
}


let triggerBronze = UNTimeIntervalNotificationTrigger(timeInterval: TimeInterval(self.pickerSegundos.selectedRow(inComponent: 0)), repeats: false)


let requestBronze = UNNotificationRequest(identifier: "XSegundos", content: contentBronze, trigger: triggerBronze)


notificationCenterBronze.getNotificationSettings { (settingsBronze) in
if settingsBronze.authorizationStatus == .authorized{

let centerBronze = UNUserNotificationCenter.current()

centerBronze.add(requestBronze) {(error: Error?) in
if let error = error {
print(error.localizedDescription)
}
}
}else {
print("Deu não")
}








}
}
}

// let request = UNNotificationRequest(identifier: "5seconds", content: content, trigger: trigger)
//
// 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: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/


Empty file modified LocalNotificationBase/Info.plist
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.