找出每天无限重复UILocalnotification被解雇的时间

时间:2023-01-23 16:51:36

If a user taps on notification that got fired few days before how to identify the date of firing? I wanted to save the date and status into the app.

如果用户点击了在如何识别解雇日期前几天被解雇的通知?我想将日期和状态保存到应用程序中。

Fire date property is giving only the start date for the notification. Is there any way to achieve this?

Fire日期属性仅提供通知的开始日期。有没有办法实现这个目标?

3 个解决方案

#1


1  

No, for a repeating local notification you can't know exactly which notification was used to open the app because they're all exact duplicates of each other.

不,对于重复的本地通知,您无法准确知道用于打开应用的确切通知,因为它们彼此完全相同。

Each time the app is opened you could remove the local notification and create a new one. This would only bound the issue, and you could do the same with a date in user defaults.

每次打开应用程序时,您都可以删除本地通知并创建一个新通知。这只会限制问题,您可以使用用户默认值中的日期执行相同的操作。

You could create explicit notifications instead of repeating if there are enough slots, this is the only way to get close to your requirement with local notifications,

如果有足够的插槽,您可以创建显式通知而不是重复,这是通过本地通知接近您的要求的唯一方法,

The alternative is push notifications where you can get the server to add additional date info to the push.

另一种方法是推送通知,您可以在其中让服务器向推送添加其他日期信息。

#2


1  

Use the property userInfo to store the repeating interval (e.g infinite or normal). In the userInfo dictionary , store the key "IsInfinite" and value as "Yes/No". By this way you can differentiate the notification type.

使用属性userInfo存储重复间隔(例如无限或正常)。在userInfo字典中,将密钥“IsInfinite”存储并将值存储为“是/否”。通过这种方式,您可以区分通知类型。

FYI: check the local notification object information also. Is repeat property is available or not?

仅供参考:还要检查本地通知对象信息。重复属性是否可用?

#3


1  

Since my app works locally so I cannot go for push notifications. Now I am firing notification in a for loop for next 90 days as a possible solution. Its seems like defect with iOS local notifications.

由于我的应用程序在本地工作,所以我不能去推送通知。现在我作为可能的解决方案在下一个90天的for循环中发出通知。它看起来像iOS本地通知的缺陷。

#1


1  

No, for a repeating local notification you can't know exactly which notification was used to open the app because they're all exact duplicates of each other.

不,对于重复的本地通知,您无法准确知道用于打开应用的确切通知,因为它们彼此完全相同。

Each time the app is opened you could remove the local notification and create a new one. This would only bound the issue, and you could do the same with a date in user defaults.

每次打开应用程序时,您都可以删除本地通知并创建一个新通知。这只会限制问题,您可以使用用户默认值中的日期执行相同的操作。

You could create explicit notifications instead of repeating if there are enough slots, this is the only way to get close to your requirement with local notifications,

如果有足够的插槽,您可以创建显式通知而不是重复,这是通过本地通知接近您的要求的唯一方法,

The alternative is push notifications where you can get the server to add additional date info to the push.

另一种方法是推送通知,您可以在其中让服务器向推送添加其他日期信息。

#2


1  

Use the property userInfo to store the repeating interval (e.g infinite or normal). In the userInfo dictionary , store the key "IsInfinite" and value as "Yes/No". By this way you can differentiate the notification type.

使用属性userInfo存储重复间隔(例如无限或正常)。在userInfo字典中,将密钥“IsInfinite”存储并将值存储为“是/否”。通过这种方式,您可以区分通知类型。

FYI: check the local notification object information also. Is repeat property is available or not?

仅供参考:还要检查本地通知对象信息。重复属性是否可用?

#3


1  

Since my app works locally so I cannot go for push notifications. Now I am firing notification in a for loop for next 90 days as a possible solution. Its seems like defect with iOS local notifications.

由于我的应用程序在本地工作,所以我不能去推送通知。现在我作为可能的解决方案在下一个90天的for循环中发出通知。它看起来像iOS本地通知的缺陷。