简体   繁体   English

内容更新时,我的IOS应用程序是否可以发送本地通知?

[英]Is it possible for my IOS app to send local notifications when content updates?

Hi i want to make an IOS app that shows tips regularly, probably pulling these tips from a blog or website of my own so that the content can be updated instantly within the app. 嗨,我想制作一个可以定期显示提示的IOS应用程序,可能是从我自己的博客或网站中提取这些提示,以便可以在应用程序中立即更新内容。 I am hoping that there is a way of sending a local notification saying for example "You have a new tip!" 我希望有一种发送本地通知的方式,例如“您有新提示!”。 after ive input some text into the blog/website that is linked to the app while its in the background? 我在后台输入一些文本到链接到该应用程序的博客/网站后? Or can i only use push for this? 或者我只能为此使用推吗?

thanks! 谢谢!

If you want your push notification to be linked to the addition of new content, I would suggest implementing remote push notifications. 如果您希望您的推送通知链接到新内容的添加,我建议您实施远程推送通知。

If this is not an option, you can always fire a UILocalNotification at a certain interval. 如果这不是一个选项,则始终可以按一定间隔触发UILocalNotification This does not need particular setup in your app, nor an external server. 这不需要您的应用程序中的特定设置,也不需要外部服务器。 You just have to create it, set a fire date, schedule it and wait for the notification to pop. 您只需要创建它,设置起火日期,安排时间并等待通知弹出即可。 The only problems are, the apps needs to run (the notification won't fire if the user kills the app), and will trigger at a certain time, not a certain context (ie added new tip). 唯一的问题是,应用程序需要运行(如果用户终止了该应用程序,则通知不会触发),并且将在特定时间而非特定上下文(即添加新提示)触发。

Little clarification 很少澄清

You could use background fetch to get data from the server, but this can cause you trouble. 可以使用后台获取从服务器获取数据,但这可能会给您带来麻烦。 The thing you need to consider is the refresh rate : if you put it too often, your server will get overwhelmed with requests. 您需要考虑的事情是刷新率:如果您过于频繁地刷新它,那么服务器将不堪重负。 Imagine if all your user ask informations to your server every hours, without exception... that can cause your serveur to crash under too high demand. 想象一下,如果所有用户无一例外地每小时都向服务器询问信息...这可能导致您的伺服器在需求过高时崩溃。

What you could do if you already know when a certain content will be added, is fetch information from the server once a day or once a week, and schedule your local notifications to fire on that day, at the wanted hour. 如果您已经知道何时添加特定内容,每天或每周一次从服务器获取信息,并安排本地通知在需要的时间在当天触发,您可以做的事情。 The problem is, if the content is removed or added and your app doesn't update, the user could receive wrong information. 问题是,如果删除或添加了内容并且您的应用程序没有更新,则用户可能会收到错误的信息。 Remote push notification is still the safest way. 远程推送通知仍然是最安全的方法。

Yes you can. 是的你可以。

You will need to get from your server the required updates on background and fire local notifications from this data. 您将需要从服务器上获取所需的后台更新,并从该数据中触发本地通知。

In this post you can see how to use background fetch to get new info, you will need every time you get new info place a local notification. 在这篇文章中,您可以看到如何使用后台获取获取新信息,每次获取新信息时都需要将其放置在本地通知中。 http://www.appcoda.com/ios7-background-fetch-programming/ http://www.appcoda.com/ios7-background-fetch-programming/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iOS 10应用程序在后台运行时,有什么方法可以触发本地通知? - Is there any way to trigger local notifications when iOS 10 app is in the background? 当手机在应用打开状态下被锁定时,iOS 6本地通知失败 - iOS 6 local notifications fail when the phone is locked with app open 在模拟器中运行应用程序时删除本地通知的iOS权限警报 - Removing iOS permission alert for local notifications when running app in simulator 在iOS中启动应用程序时显示本地通知 - Displaying local notifications when app starts up in iOS iOS,应用启动时如何处理多个本地通知? - IOS, how to handle multiple local notifications when app start? (iOS)当应用程序不再运行时取消所有本地通知 - (iOS) Cancelling all local notifications when app is no longer running iOS设置-通知:如果我不使用本地通知,如何删除我的应用程序? - iOS Settings - Notifications: How to remove my App if I do not use local notifications? 当我的应用程序在后台运行时,是否可以在通知上设置PresentationsOptions? - Is that possible to set PresentationsOptions on notifications when my app is on background? 在后台运行的应用发送本地通知 - App running in the background send local notifications 不使用应用程序时发送通知? - Send notifications when the app is not used?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM