import UIKit
class MyView: UIViewController {
@IBOutlet var mySwitch: UISwitch!
@IBOutlet var myDatePicker: UIDatePicker!
func datePicker() { myDatePicker.datePickerMode = UIDatePickerMode.Date }
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
datePicker()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func switchPressed(sender: AnyObject) {
if mySwitch.on{
var localNotification:UILocalNotification = UILocalNotification()
localNotification.alertAction = "Open App"
localNotification.alertBody = "Here is your notification at 7:00 AM"
localNotification.fireDate = myDatePicker.date
localNotification.repeatInterval = NSCalendarUnit.CalendarUnitDay
UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
} else {
var localNotification:UILocalNotification = UILocalNotification()
localNotification.alertAction = "Open App"
localNotification.alertBody = "This notification should not appear"
localNotification.fireDate = NSDate(timeIntervalSinceNow: 999999999999)
IApplication.sharedApplication().scheduleLocalNotification(localNotification)
}
}
}
//
// ViewController.swift
// Combining Date and Time
//
// Created by Leonardo Savio Dabus on 08/12/2014.
// Copyright (c) 2014 inDabusiness.com. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
// IBOutlet goes here
@IBOutlet var myDatePicker: UIDatePicker!
@IBOutlet var mySwitch: UISwitch!
// let = whatever goes here
// var = whatever goes here
var localNotification = UILocalNotification() // You just need one
var notificationsCounter = 0
// put your functions now
func datePicker() { myDatePicker.datePickerMode = UIDatePickerMode.Date }
func datePickerDefaultDate() { myDatePicker.date = NSDate().xDays(+1) }
func notificationsOptions() {
localNotification.timeZone = NSTimeZone.localTimeZone()
localNotification.repeatInterval = .CalendarUnitDay
UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
localNotification.alertAction = "Open App"
localNotification.alertBody = "Here is the seven o'clock notification"
localNotification.soundName = UILocalNotificationDefaultSoundName
localNotification.applicationIconBadgeNumber = UIApplication.sharedApplication().applicationIconBadgeNumber + 1
// you may add arbitrary key-value pairs to this dictionary.
// However, the keys and values must be valid property-list types
// if any are not, an exception is raised.
// localNotification.userInfo = [NSObject : AnyObject]?
}
func toggleSwitch(){
if mySwitch.on{
localNotification.fireDate = myDatePicker.date.fireDate // combined date = picked Date + 7:00am time
} else {
localNotification.fireDate = NSDate(timeIntervalSinceNow: 999999999999) // will never be fired
}
}
override func viewDidLoad() {
super.viewDidLoad()
datePicker()
datePickerDefaultDate()
notificationsOptions()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// here is where you place your IBActions
@IBAction func switchPressed(sender: AnyObject) {
toggleSwitch()
}
}
在您的项目中创建一个新的Swift Source文件以放置扩展
import Foundation
public extension NSDate {
func xDays(x:Int) -> NSDate {
return NSCalendar.currentCalendar().dateByAddingUnit(.CalendarUnitDay, value: x, toDate: self, options: nil)!
}
var day: Int { return NSCalendar.currentCalendar().components(NSCalendarUnit.CalendarUnitDay, fromDate: self).day }
var month: Int { return NSCalendar.currentCalendar().components(NSCalendarUnit.CalendarUnitMonth, fromDate: self).month }
var year: Int { return NSCalendar.currentCalendar().components(NSCalendarUnit.CalendarUnitYear, fromDate: self).year }
var fireDate: NSDate { return NSCalendar.currentCalendar().dateWithEra(1, year: year, month: month, day: day, hour: 7, minute: 0, second: 0, nanosecond: 0)! }
}
Navicat Monitor 提供 4 个通道(电子邮件,SNMP 陷阱、Slack 通知和 SMS 消息),让你在监控引发警报时发送通知。若要配置警报通知,请前往“配置”->“通知”。 电子邮件通知 在“电子邮件”部分,启用“引发警报”。 配置以下信息: SMTP 服务器 为传出消息输入你的简单邮件传输协议(SMTP)服务器。 端口 输入你连接到传出电子邮件(SMTP)服务器的端口号。 需要安
在我的iOS应用程序中,我需要通知用户远程设备上的一些紧急事件。无论应用程序的状态如何,用户都需要获得警报:如果应用程序处于前台、后台模式,甚至被杀死。 根据Apple文档,只有“voip”后台模式允许“保持活动”功能在后台与服务器保持连接。但“voip”模式只允许用于真正的voip应用程序,我的应用程序不提供任何voip服务。因此,我认为我的案例的唯一选择是使用Apple推送通知。 当用户的iO
请求header POST /v1/notify Authorization:Bearer {ACCESS TOKEN} Content-Type:application/json 注:请将上方的{ACCESS TOKEN}替换为您的ACCESS TOKEN 请求payload { "url":"http://www.foo.com/" } payload参数说明 参数 参数说明 参数
问题内容: 我知道这个问题以前曾被问过,但我已不知所措。 我有一个警报管理器来设置通知: …然后我得到了通知本身即服务: } ....我加入了吐司,以确保我确实要使用此方法。敬酒,但通知没有。我在这里做错了什么?我需要更改清单文件中的内容吗? 问题答案: 没有图标(或标题是?)的通知将不起作用。 我确信我遇到了同样的问题,因为如果您忽略了通知的内容之一,则通知将不会显示。
> 在移动应用程序中为用户分配一些数据标签,例如“HAS Items:true”或“Is interestedinProduct”,然后用这些用户标签在Oneignal控制台中创建片段。 在我的后端保存Oneignal,将其与匹配,然后根据后端数据库数据有选择地向用户发送消息。 做这件事的首选方法是什么?或者它应该是两者的结合,这取决于我的用例?有没有办法让它完全自动化?例如。根据一些分析事件,在