I need to re-show an uilocalnotification again after user unlock his iphone, because the notification is an incoming call. Currently, after user unlock his iphone, the notification is "gone" back to the notification center, and the ringtone is silent as well. User have to manually pull down notification center to see the call notification.
I wonder how Whatsapp deal with situation like this? Whatsapp will re-display the top banner notification again after I unlock my phone.
I searched google and found 2 ways as below:
Using NSTimer to schedule cancelLocalNotification() and presentLocalNotification() again . I tried this but I got double same notification and NSTimer fails to run more than twice, although it was set to repeat.
Using com.apple.springboard.lockstate to detect when user unlocked their phone . But is it private API that can lead to rejection on app store?
Thanks!
Related
I am building my first app but wanted to know if there is a way to send updates or activity notifications to a user without a push notification.
These updates could include:
icon badge
Sound
Alert that appears on the lockscreen (I believe this is the push notification)
What can be done without requiring the user to give permission? I have tasks for the user at x time and want to remind them at that time.
i have an application that receive push notifications, i would like to implement a user settings profile with a "silent notification for x hours".
How can i prevent the sound of the notification? there's a something on a server or in a client?
Because now i can prevent the sound if the app is in foreground or background, but if the app is suspended how can i intercept and lock the sound and the notification?
Somethings like whatsapp or telegram application!
Thanks!
Upload the user settings to the server and ensure that the server doesn't send any push notification during the silent hours. During that time if the user opens the app they should be able to download the content but they shouldn't be notified about any new content when the app isn't already open.
I'm looking to push a notification to the Apple Watch at a specific time. I was able to display a static message on the simulator using an apns file, but I'd like to set the data and time of the notification in the controller.
I heard I might not be able to do this on a simulator, but if I got a real phone and watch, how would it work?
So, you want to do something in the watch app extension and based on the results, schedule a UILocalNotification that will be sent to the phone at some point?
You cannot directly schedule a UILocalNotification from the watch because you don't have access to the UIApplication object. See Apple staff comment here. However, using Watch Connectivity, you could send a message from the watch to the phone and have the phone app create and schedule it in the background. The watch will display the notification iff the phone is locked at the trigger time. The watch's notification scene will be invoked in that case.
Assuming you want to send the notification from the phone to the watch: You can use UILocalNotification to send a notification to the watch - but the watch must be locked to receive it. There's also no guarantee when the Watch OS will turn on the watch to run the code that receives your notification, so your notification may arrive minutes or hours after it's sent.
My app has notification feature. When I receive a notification I show a badge in my app icon.
As I know, when my app is on background, since user does not clicks on the notification at notification center, my app does not know that it has a notification. So it can not change the badge number.
Also from this topic:
Detect when a user clears notification from the notification center
If user clears the app's notification, the app can not detect it.
So the problem is here:
- My app is on background
- User receives a notification related to the app
- App adds a badge with number 1 to the app's icon
- User deletes the notification from notification center
- App never understands that notification has been removed so that it can remove the badge!!!
So how other apps fix this problem? Is there any solution for this?
There is no way to check when the user clears notifications for your app.
The usual practice for clearing the app badge is when the user has viewed the applicable content within your app (e.g. messages in a messaging app), or otherwise just clearing the badge the next time the user opens your app if this is not applicable, or you can't easily segment the notifications and connect them to viewable content in your app.
Note: you should not be relying on the user tapping on your notifications in order to get their content. If your user doesn't tap your notification, your app has no way of ever finding out its content, or that it ever existed.
Instead, when your app is opened, it should connect to your server to download updated content, then you can use this complete, accurate information to update your app badge as required. Do not try to fetch content from your notifications.
You can add custom action to your notification: "Mark as read" or "Delete". Remove badge in -application:handleActionWithIdentifier:... method.
Yes, it doesn't allow you to detect user cleans the notification. But there is no any way to do it. So I suggest a workaround to solve this problem.
As per title.
I'd like to send a push notification to a remote user. When the user receives it, the phone vibrates in a custom pattern while locked.
Is this possible? How would it be done?