Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.8k views
in Technique[技术] by (71.8m points)

ios - How to fire scheduled notification with different content in Swift?

I have the iOS app on Swift (UIKit). Let's say I have the next array: ["a","b","c","d","e","f","g","j","h","k"]

I would like to:

  • fire notification every 1 hour,
  • notification should take a random letter from array and fire it as a text inside notification.

While implementing that I came across with the next issues:

  • local notifications fire well (every one hour), but I can't change inner text dynamically;
  • push notifications (that use CloudKit database) are able to throw only if there is one of events: add/edit/delete record in CloudKit database.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

A local notification cannot run any code when it fires. It has a fixed payload and that is what displays. The notification does not pass thru your app after you schedule it; the system does the firing and displaying for you. So a local notification is probably not what you are looking for here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...