当我的iOS应用程序在后台运行时,它可以很好地响应
- (void)application:(UIApplication *)application didReceiveLocalNotification:
(UILocalNotification *)notification
Run Code Online (Sandbox Code Playgroud)
但是当应用程序关闭时,它会崩溃并发出SIGKILL错误.
如果在收到通知时关闭了应用程序,如何在应用程序中运行该方法?
我需要设置UILocalNotification,我只需要从DatePicker获取小时和分钟,并需要设置特定日期 (如:星期一)并在每个星期一重复.
我有两个问题:
第一 ; 是否可以在日期选择器的日期部分仅显示"日期名称",如"星期日"?
第二个问题是; 如果我想设置本地通知的具体日期,那么正确的代码是什么?
谢谢你的答案,下面是我的代码;
-(IBAction) alarmButton:(id)sender {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
dateFormatter.timeZone = [NSTimeZone defaultTimeZone];
dateFormatter.timeStyle = NSDateFormatterShortStyle;
dateFormatter.dateStyle = NSDateFormatterShortStyle;
NSString *dateTimeString = [dateFormatter stringFromDate: dateTimePickerSet1.date];
NSLog ( @"Alarm Set :%@" , dateTimeString);
[self scheduleLocalNotificationWithDate1: dateTimePickerSet1.date];
}
-(void)scheduleLocalNotificationWithDate1:(NSDate *)fireDate {
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.fireDate = fireDate;
notification.alertBody = @"Alarm Set !";
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
Run Code Online (Sandbox Code Playgroud) 我对Android中的本地通知有疑问.我正在开发一个应用程序,其中第一部分必须接收我自己的服务器公司的所有会议(我已经实现),第二部分我必须在每次会议前一天通知,但有本地通知.
如何在给定日期安排本地通知?
我正在开发一个带有cordova的应用程序,我正在使用这个插件来安排每天到6点的本地通知 https://github.com/katzer/cordova-plugin-local-notifications
一切正常,这是我用来设置de Notification的代码
Run Code Online (Sandbox Code Playgroud)/*Set 6 o'clock*/ function setTestAlarm() { var notify = new Date(); notify.setHours(18,00,00,00); localNotification.add({ id: 1, title: 'My app', message: 'Hi this is a notification', repeat: 'daily', date: notify, autoCancel: true, ongoing: true, });
我正在进行测试,并且通知每天下午6点出现,但仅连续9天,然后停止出现.我究竟做错了什么?
谢谢
我正在深入研究iOS开发,并且一直在研究闹钟应用程序以熟悉iOS平台和SDK.我正在使用本地通知处理我的警报,但我需要一些管理我设置的本地通知的方法,以便在我编辑或删除与它们相关的任何警报时可以更新它们.我想出了如何在计划cancelLocalNotification:后使用函数取消计划本地通知,但我很难弄清楚如何检索与编辑或删除的警报关联的本地通知对象,以便我可以使用该功能.我应该注意,用于创建本地通知的所有警报对象都存储在Core Data DB中,其界面定义为......
@interface Alarm : NSManagedObject
{
}
@property (nonatomic, retain) NSNumber * Snooze;
@property (nonatomic, retain) NSNumber * AlarmID;
@property (nonatomic, retain) NSString * Label;
@property (nonatomic, retain) NSDate * Repeat;
@property (nonatomic, retain) NSDate * Time;
@property (nonatomic, retain) NSNumber * Enabled;
@property (nonatomic, retain) NSString * Song;
@property (nonatomic, retain) NSString * Sound;
@end
Run Code Online (Sandbox Code Playgroud)
非常感谢您的帮助!
我正在使用ionic来构建android应用。我正在使用
$cordovaLocalNotification本地通知。通知有效,但显示默认的响铃图标。如何自定义通知图标?
任何人都可以向我展示如何使用本地通知插件在颤振中安排通知的代码。尝试了 git 存储库中的示例,购买它对我不起作用,尽管正常通知正在工作,但我如何将其安排在特定时间,例如提醒?
我正在使用 flutter 应用程序设置 fcm,并使用本地通知在应用程序位于前台时显示通知。
在 android 中它运行完美,没有任何错误。但在 IOS 上本地通知不起作用。它没有显示错误或任何内容,但是当应用程序位于前台时,它现在根本显示通知横幅
这是本地通知的设置:
var android = AndroidInitializationSettings('mipmap/ic_launcher');
var ios = IOSInitializationSettings();
var platform = new InitializationSettings(android, ios);
flutterLocalNotificationsPlugin.initialize(platform);
_firebaseMessaging.requestNotificationPermissions(
const IosNotificationSettings(sound: true, badge: true, alert: true, provisional: false));
Run Code Online (Sandbox Code Playgroud)
然后是 showNotification 函数,如下所示:
showNotification(Map<String, dynamic> message) async {
var android = new AndroidNotificationDetails(
'IMPORTANT1', 'SHOW BANNER', 'ALWAYS SHOWS BANNER',
importance: Importance.Max, priority: Priority.High, ticker: 'ticker');
var ios = new IOSNotificationDetails();
var platform = NotificationDetails(android, ios);
await flutterLocalNotificationsPlugin.show(
0,
message['notification']['title'],
message['notification']['body'],
platform); }
Run Code Online (Sandbox Code Playgroud)
我通过互联网搜索并发现我需要使用这个
if #available(iOS …Run Code Online (Sandbox Code Playgroud) 我编写了这个简单的代码来尝试本地通知如何与核心数据一起工作,主要问题是,在添加数据核心项目后,我可以在 60 秒后收到我的通知,但如果我删除它,我仍然会收到它。当我调用 deleteItem 函数时,是否可以调用一个函数来删除该特定通知?
我的另一个问题是如何设置星期几和触发该通知的时间,而不是在几秒钟后重复?
内容视图:
import UserNotifications
import SwiftUI
import CoreData
struct ContentView: View {
//Core Data
@Environment(\.managedObjectContext) var managedObjectContext
@FetchRequest(entity: Notifications.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \Notifications.date, ascending: false)]) var notifications: FetchedResults<Notifications>
var titles = ["Hello", "Weekend", "Streaming", "ScoobyDoo"]
var subtitles = ["Hello2", "Weekend2", "Streaming2", "ScoobyDoo2"]
var body: some View {
NavigationView {
VStack {
NavigationLink(destination: FavoriteView()) {
Text("Favorite View")
}
List {
ForEach(0 ..< titles.count) {title in
HStack {
Text(self.titles[title])
Image(systemName: "heart")
.onTapGesture {
if self.checkItem(title: self.titles[title]) {
do …Run Code Online (Sandbox Code Playgroud) core-data localnotification uilocalnotification swift swiftui