I developed a game and I have a text list. I want to display this text list on tableview cells line by line.
I can display one line on tableview cells. And when the app is on background, I want to display the next line on this text list with local notification. When scheduled local notification is clicked or displayed, and when the app is in the foreground, I want to see that lines. How can I do this?
Edit: I expand my question. I have a text list like this:
Line1: Body: "Hi, I am here" , FireDate: 2 seconds
Line2: Body: "Where are you" , FireDate: 5 seconds
I want to show only "body" content if App is on foreground. And after "firedate" i want to Show the next line on tableview. If App is on background, i want to Show and schedule these lines by local notifications with these firedates. If user opens App, i want to Show these lines in tableview cells.
I know that this question is about local notifications and tableviews. Not for one. Because i dont know where i should start and go. With local notifications or tableviews? I mean that shoul i write the code for tableview and then schedule local notifications? Or together?
Learn and set up your local notification system first. Create your model class(es), send out a local notification, then handle capturing what the user did in the local notification and update your model classes as a result. Focus on that and get it fully working. Add some very simple temporary UI to your app so you can see the results, or simply print messages to console is fine. Dealing with how to reflect your model into a view such as a tableView is completely orthogonal and thus separately solvable. It shouldn't affect your local notification design at all.
Related
I'd like to implement daily local notifications, at the same time each day, but with different content. All examples I have seen are with repeating the same content.
In Android I can set an alarm to trigger a portion of my app which then creates the custom content for the day, and pushes that content as notification. How do I do the same in iOS?
I have an app that contains stopwatch and when time is running and the app enters background I would like to have a notification on lock screen and in Notification Center (when you swipe down). The notification should contain actual time of the stopwatches and user should be able to stop/start the stopwatches.
I was trying to achieve this using UNNotificationContentExtension but as documentation says:
When an iOS device receives a notification containing an alert, the system displays the contents of the alert in two stages. Initially, it displays an abbreviated banner with the title, subtitle, and two to four lines of body text from the notification. If the user presses the abbreviated banner, iOS displays the full notification interface, including any notification-related actions. The system provides the interface for the abbreviated banner, but you can customize the full interface using a notification content app extension.
I found out that I am able to edit just full notification interface which means that when user gets notification and opens it I can show him whatever I want (I tried mediaPlayPauseButtonType to handle stopwatches). But when I check the lockscreen the notification stays default.
What are the possibilities to achieve Notification similar to Spotify - when you play song, you can pause the song and you can see the time etc. from the lockscreen?
Thanks!
I observed that iMessage preserves last typed message in a chat even if I move to another chat and come back to it.
For eg. I am in Chat1 and typing. Then without sending the message I move to Chat2 and then come back to Chat1. Last typed message is still there.
If I understand correctly, when I press back button in Chat1, it should execute viewWillDisappear which should destroy all local elements.
Then how is last typed message still there?
iMessage is not the only app which does it. Whatsapp also does it. Even you open a chat in whatsapp scroll to older message->go back->and come again on the same chat. You will see the old state of chat.
The Recommended way to do it is App State Restoration if you want to store the whole state of your controller with more UI elements and values.
You can check following tutorial available for this..
https://www.raywenderlich.com/117471/state-restoration-tutorial
http://useyourloaf.com/blog/state-preservation-and-restoration/
I'm working on a project on iOS 7, 8 that use a lot of notifications (Remote, Local). I have some questions about Local Notification.
I'm using Local Notification to schedule an alarm or a count-down. As I know, the use of NSTimer is not really a good choice since it has only up to 10' in background & if the app process is killed it doesn't work anymore. Local Notification is managed by iOS but I have to accept its alert when the app is not in foreground. There's nothing like silent local notification (local notification without alert, sound or badge and app still knows about it although it's in background). Am I right ?
Let's assume that there're some simple local notifications in Notification Center, scheduled by our app. Normally when I touch on a notification to see it in my app, the others remain present until we interact with them. In some cases that I haven't figured out, all other notifications are removed from the Notification Center. Does anyone encounter this & understand why ?
I find the interactive notification feature in iOS very limited. I want to change the title of a defined UIMutableUserNotificationAction button & add an image for it, like I can do with UIButton. So the question is : Is it possible to customize the UI of an action button ?
Thanks for your help !
Unfortunately there is no correspondence in silent notification using local notifications.
The number of the visible notification in the notification center is a user decision, the user in Settings can decide to set a different number or decide to do not show them in notification center as well. As for the first point no. The third point is not clear, you can set the image you want for a remote just put in the payload the right name, local notifications use the app icon.
There is no silent notification for Local Notification. The user has to click to the notification to open your App.
I suppose that the associated application has deleted those notifications programmatically. Else, those notifications must stay in the notification center.
You cannot add image to action buttons but just the titles.
I tried more than two weeks to do the same. I had to show notification after 2 hrs even if the use doesn't click the notification. But the repetition facility is well handled in objective C. I could have created multiple local notification but it will also violates the total number of 64 notifications. Apple needs to improved the same.
I found lots of "reloadData" for TableView questions here, but my case is different.
I have a notification App, that uses UILocalNotification to fire reminders.
I need to refresh my tableview in real time after an alert fires, without the need of closing and opening the app to do so...
Example:
User is viewing the scheduled reminders (tableView), when suddenly one of the reminders fires. At this moment, the tableView will reload, but only if the user quits application or go back to another view and open the tableView again. That can't happen cause the application breaks if the user press the row in the tableView witch showed the current reminder (that's already completed and doesn't exists anymore).
I need to reload tableView in real time, without leaving the tableView Controller view. any idea on how to do that?
When a local notification for your app fires while the app is in the foreground, the system sends the application:didReceiveLocalNotification: message to your app delegate. From there, you should notify the view controller (via a direct reference and message send or possibly with a custom NSNotification) to do whatever it needs to do in this case.