标签: uilocalnotification

在Phonegap,Corona或Monotouch上可以在iOS上进行位置感知通知吗?

像其他人一样,我正在冒险进入移动应用程序开发,我正在寻找不同的框架/语言.对我来说最吸引人的是Phonegap,Corona SDK和Monotouch.目标C似乎有点太低了.我很长时间没有做过记忆管理,我也不想重温那段经历.但如果我需要去满足客户的需求,我会去那里.

在这种情况下,客户端需要iOS应用中的位置感知通知.

用户故事是这样的:用户在城外散步.她把她的iPhone放在口袋里,正在通过iTunes听音乐.当她走进她当地的商场时,我的应用程序(在后台运行)检测到她在她银行的一个分支附近.我的应用程序也知道用户在银行有一些差事.因此,我的应用程序会中断当前正在播放的iTunes曲目,播放通知声音并在屏幕上显示通知文本,告诉用户附近有一个银行办公室,并且她现在可能想要执行该银行差事.

这可以通过Phonegap,Corona SDK或Monotouch完成吗?

geolocation xamarin.ios uilocalnotification coronasdk cordova

2
推荐指数
1
解决办法
927
查看次数

UILocalNotifcation - 即使通过主屏幕启动应用程序,也会响应通知

我在我的应用程序中发送本地通知; 如果用户响应通知,app会调用下面的委托方法,我可以处理它:

  - (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif 
Run Code Online (Sandbox Code Playgroud)

如果用户没有响应通知但之后打开应用程序,我希望以与响应通知时相同的方式处理它.

我还检查了应用程序是否使用启动选项启动,但只有在它们直接响应通知时才会调用它.

检查通知是否已被触发但用户已自行响应的最佳方法是什么?

iphone objective-c uilocalnotification

2
推荐指数
1
解决办法
232
查看次数

如何在明天早上8点创建一个日期对象

我通常对此很好,但我遇到了这个问题NSDate.我需要NSDate明天早上8点(相对)设置一个对象.我该怎么做?什么是最简单的方法?

objective-c nsdate nsdatecomponents uilocalnotification

2
推荐指数
1
解决办法
2866
查看次数

我如何在UILocalNotification中更改UserInfo?

我有6个UILocalNotifications.每个通知都有自己的"userInfo"

  1. @ "1"
  2. @ "2"
  3. @ "3"
  4. @ "4"
  5. @ "5"
  6. @ "6"

然后我删除通知号4,并有5个通知:

  1. @ "1"
  2. @ "2"
  3. @ "3"
  4. @ "5"
  5. @ "6"

如何在通知中更改"userInfo"以获取:

  1. @ "1"
  2. @ "2"
  3. @ "3"
  4. @ "4"
  5. @ "5"

保存代码 -

// Specify custom data for the notification

NSDictionary *infoDict = [NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"%i", i] forKey:@"notif"];
localNotif.userInfo = infoDict;
 i = i + 1;
Run Code Online (Sandbox Code Playgroud)

德尔代码 -

if (flagTable == 1)
{
    int numberPhoto = [[[UIApplication sharedApplication] scheduledLocalNotifications] count];
    int numPhFlag = …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios uilocalnotification

2
推荐指数
1
解决办法
5589
查看次数

如何增加/减少UILocalnotification的application.badge数

当多个通知被触发时我有UILocalnotification我希望应用程序徽章编号获得增量,并且当看到通知时我希望应用程序徽章编号减少取决于取消/观看通知的通知数量

 - (UILocalNotification *)scheduleNotification :(int)remedyID
{
        NSString *descriptionBody;
        NSInteger frequency;

        UILocalNotification *notif = [[UILocalNotification alloc] init];


        descriptionBody =[[self remedyDetailsForRemedyID:remedyID] objectForKey:@"RemedyTxtDic"];
        frequency = [[[self remedyDetailsForRemedyID:remedyID] objectForKey:@"RemedyFrequency"]intValue];

        NSArray *notificationFireDates = [self fireDatesForFrequency:frequency];

        for (NSDate *fireDate in notificationFireDates)
        {
                notif.timeZone = [NSTimeZone defaultTimeZone];


                notif.repeatInterval = NSDayCalendarUnit;
                notif.alertBody = [NSString stringWithString:descriptionBody];
                notif.alertAction = @"Show me";
                notif.soundName = UILocalNotificationDefaultSoundName;

                notif.applicationIconBadgeNumber = 1;

                notif.fireDate = fireDate;


                NSDictionary *userDict = [NSDictionary dictionaryWithObjectsAndKeys:notif.alertBody,                                         @"kRemindMeNotificationDataKey",  [NSNumber numberWithInt:remedyID],kRemindMeNotificationRemedyIDKey,
                                          nil];

                notif.userInfo = userDict;

                [[UIApplication sharedApplication] scheduleLocalNotification:notif];
            }

            return notif;

}

} …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios uilocalnotification

2
推荐指数
1
解决办法
4901
查看次数

iOS 限制 64 个本地通知

我知道这个主题是重复的,但我需要你的帮助。这对我来说非常重要,其他帖子对我来说没有真正的解决方案。

我有一个应用程序(Swift 2),用户可以在其中保存核心数据中的条目。这些整体将显示在表格视图中。

用户必须为每个条目设置提醒日期(使用日期选择器)。此日期将用作本地通知的触发日期。每个条目获得 2 个本地通知

第一个开火日期:所选日期前 1 周,第二个开火日期:所选日期

问题是 Apple 对 64 个本地通知的限制。用户只能保存 32 个条目(32 个条目 * 2 个通知 = 64 个通知)

如何通过限制解决这个问题?

我知道我可以在 Apple 日历中设置“提醒”而不是本地通知。但这看起来不太好 - 这不应该是解决方案。

我知道我可以检查每个应用程序的启动或方法确实收到通知,接下来应该设置哪些通知。但为此我必须相信,用户启动应用程序或点击收到的通知。如果他或她几天没有这样做 => 不会设置新的通知,他或她也不会收到下一个通知。这个解决方案不是很安全。

cocoa-touch ios uilocalnotification

2
推荐指数
1
解决办法
6248
查看次数

如何从 Swift 中的句子中获取第一个单词

我试图从String句子中获取第一个单词作为变量。怎么做?我有本地通知,我需要使用它的消息第一个词作为变量,这可能吗?因为LocalNotifications我使用LocalNotificationHelper库来更容易处理。也许有逻辑问题,但我不这么认为。更像是我对Swift语言的选择不够了解。

编辑:我也有nameField.text!NSUserDefaults为一个数组。我需要从该数组中删除消息的第一个单词。现在我只从该数组中删除了第一个对象,但这对我来说不是解决方案,因为我需要删除 nameField.text!当 LocalNotification 弹出并用户单击按钮时,从该数组中。

我在这里创建通知消息:

LocalNotificationHelper.sharedInstance().scheduleNotificationWithKey("text", title: "see options(left)", message: nameField.text!+"some text", date: deadlinePicker.date, userInfo: userInfo)
Run Code Online (Sandbox Code Playgroud)

现在我需要message:nameField.text!在应用程序启动时可变。

这就是我触发通知按钮操作的方式:

NSNotificationCenter.defaultCenter().addObserver(self, selector: "someFunction:", name: IDENTIFIER, object: nil)
Run Code Online (Sandbox Code Playgroud)

string uilocalnotification swift

2
推荐指数
1
解决办法
3093
查看次数

Swift - 本地通知不会被触发

我编码斯威夫特3,我只是试图发送一个通知,现在没有任何延迟或间隔.但是通知永远不会被触发.这是我的代码..

ViewController代码

import UserNotifications

class HomeViewController: UIViewController{
    var isGrantedNotificationAccess:Bool = false

    override func viewDidLoad() {
        super.viewDidLoad()

        UNUserNotificationCenter.current().requestAuthorization(
            options: [.alert,.sound,.badge],
            completionHandler: { (granted,error) in
                self.isGrantedNotificationAccess = granted
        })

        if isGrantedNotificationAccess{
            triggerNotification()
        }
    }

    //triggerNotification func goes here
}
Run Code Online (Sandbox Code Playgroud)

triggerNotification函数:

func triggerNotification(){
    let content = UNMutableNotificationContent()
    content.title = NSString.localizedUserNotificationString(forKey: "Notification Testing", arguments: nil)
    content.body = NSString.localizedUserNotificationString(forKey: "This is a test", arguments: nil)
    content.sound = UNNotificationSound.default()
    content.badge = (UIApplication.shared.applicationIconBadgeNumber + 1) as NSNumber;
    let trigger = UNTimeIntervalNotificationTrigger(
        timeInterval: 1.0,
        repeats: false) …
Run Code Online (Sandbox Code Playgroud)

xcode notifications ios uilocalnotification swift

2
推荐指数
1
解决办法
2626
查看次数

iOS 10中不显示本地通知

我在Appdelegates中尝试过此代码.

@import UserNotifications;


UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
    [center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert)
        completionHandler:^(BOOL granted, NSError * _Nullable error) {
            if (!error) {
            NSLog(@"request authorization succeeded!");

                center.delegate = self;
            }
    }];
Run Code Online (Sandbox Code Playgroud)

并且此代码触发了本地通知

-(void)localNotification{

NSLog(@"local notification fired");

UNMutableNotificationContent *objNotificationContent = [[UNMutableNotificationContent alloc] init];

objNotificationContent.title = @"local notificatin";

objNotificationContent.body = @"message";

objNotificationContent.sound = [UNNotificationSound defaultSound];

/// 4. update application icon badge number
objNotificationContent.badge = @([[UIApplication sharedApplication] applicationIconBadgeNumber] + 1);

// Deliver the notification in five seconds.
UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger
                                              triggerWithTimeInterval:0.3 …
Run Code Online (Sandbox Code Playgroud)

objective-c ios uilocalnotification

2
推荐指数
1
解决办法
5351
查看次数

设置特定日期和时间的本地通知swift 3

在我的应用程序中,我想添加本地通知.方案是用户可以选择从周一到周日的任何时间和日期.例如,如果用户选择Mon,Thur和Sat作为日期和时间为晚上11:00,那么现在应该在所有选定的日期和特定时间通知用户.

码:

 let notification = UNMutableNotificationContent()
 notification.title = "Danger Will Robinson"
 notification.subtitle = "Something This Way Comes"
 notification.body = "I need to tell you something, but first read this."

 let notificationTrigger = UNTimeIntervalNotificationTrigger(timeInterval: 60, repeats: true)
 // let test = UNCalendarNotificationTrigger()
 let request = UNNotificationRequest(identifier: "notification1", content: notification, trigger: notificationTrigger)
 UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
Run Code Online (Sandbox Code Playgroud)

我正在使用此代码,但这不符合我的需要.

ios uilocalnotification swift3

2
推荐指数
1
解决办法
2121
查看次数