Detect New Day on watchOS While App Is Open - watchos

I'm currently working on my first watchOS app extension, which is based on Xcode's Multiplatform template. I'm looking for a solution that will allow me to detect a significant date change, such as the observation of midnight, when the watch app is open. However, I've been unable to find such a solution. I'd like to avoid using Timers, if possible.
I'm able to observe UIApplication.significantTimeChangeNotification (iOS) and Notification.Name.NSCalendarDayChanged (macOS), but I've not found a similar notification for watchOS. What I did find in the documentation for WKExtension are notifications that are similar to iOS app lifecycle notifications.
What I want is to update the UI of the watchOS app when it's open and a new day is observed, which UIApplication.significantTimeChangeNotification gets me on iOS. Is there a way for the watch app to observe a date change when the app is open on the watch?

You can use .NSCalendarDayChanged on watchOS as well:
NotificationCenter.default.addObserver(
self,
selector: #selector(dayChanged(_:)),
name: .NSCalendarDayChanged,
object: nil
)

Related

Alarm Functionality In ReactNative For Android And iOS

I want to make app that play music every day at specific time (for example : 07:00) even if the app in background or turned off
I had done it in android with Java & Android SDK using Alarm Manager , i'm looking for something like that for ReactNative
I had searched for libraries but i did not found useful resources
check this out https://github.com/wmcmahan/react-native-calendar-events , The alarms associated with the calendar event, as an array of alarm objects.

How do I notify users of new content available in tvOS apps from the home screen?

Push notifications have been left out of tvOS (understandably so) but the docs seem to contradict themselves in alerting users to the fact that there is something new available in your tvOS app.
Here it seems to say that you can add an app badge: https://developer.apple.com/library/prerelease/tvos/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/WhatAreRemoteNotif.html
Here it says they've been removed from UIKit: https://developer.apple.com/library/prerelease/tvos/releasenotes/General/tvOS90APIDiffs/Objective-C/UIKit.html
Removed UIApplication.applicationIconBadgeNumber
Assuming the badge approach is not supported in this release, does anyone know the best practice for alerting a user that there is new content in your app without the user taking an explicit action? ie focusing on the app and showing them something in TopShelf?
I encountered the same problem and dived into this. Probably your best way is to update the topshelf with latest items, which is my way to solve this for now. You can use network calls to update the topshelf with content from your backend.
This depends on the type of application. E.g. showing the latest top movies for a movies app.
You can trigger an update of the topshelf after your network call completed using the following code:
NSNotificationCenter.defaultCenter().postNotificationName(TVTopShelfItemsDidChangeNotification, object: nil)
Make sure to implement the TVTopShelfProvider which should be clear using the following documentation:
This protocol is adopted by the principal class of an app’s TV Services extension. Apps that implement this extension can provide dynamic content to the Top Shelf element rather than having the system use the static image submitted with the app. The topShelfStyle property specifies the interface style you want, and the topShelfItems property specifies the content items to display. Whenever you change the content provided by the extension, post a TVTopShelfItemsDidChangeNotification notification to prompt the system to reload your content.
Icon badges are removed for app icons, push notifications as well (except for silent push notifications).

How to open the apple app store internally using a modal segue

I am currently making an app that recommends other apps to download on the apple app store. I assumed that the only way for users to download these linked apps was to call the iTunes URL of the particular app -> the apple app store would then open pushing the original calling app into the background -> then the user would press the download button here as per normal.
Then I was playing with the app "App Hero" and they do something I thought wasn't possible. You can actually download another app to your device without ever leaving the "App Hero" application. I thought this was impossible due to sandboxing. They have a modal segue to what appears to be an embedded app store where you can commence installation of another app. This "embedded" app store doesn't have the usual UITabBar running along the bottom but everything else is basically the same.
Does anyone have any idea how they would have achieved this? It doesn't appear to be a UIWebView, perhaps I am wrong. And is this against any of the apple regulations?
*This is no way an advertisement for "App Hero". I am genuinely impressed/confused how they are able to do this and would love this functionality in my own app if it is allowed.
The class you are looking for is called SKStoreProductViewController. Docs here.

Is there any way to access an iTunes library to set an alarm tone?

Is there any way to access an iTunes library to set an alarm tone?
I am building an alarm app. I think we can can use local notifications when my app is in the background, but it can't play music library sounds. So when the app is in foreground, I want to play sounds from the music library and songs from my app bundle as well. How might I achieve this?
You can select the music libray of your device using the MPMusicPlayerController.
For this you need to include the MediaPlayer.framework framework and <MediaPlayer/MediaPlayer.h> header file.
You will get the picked music url using this delegate method (for this you need to add the MPMediaPickerControllerDelegate in #interface) :
- (void)mediaPicker: (MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection
{
}
Refer this tutorial for a detailed description.

iOS 5: Can I have my app "In Notification Center" by default?

I have an iPad app in the App Store whose logic relies largely on local notifications. In other words, much that happens inside the app is triggered by the delegate method application didReceiveLocalNotification.
With today's release of iOS 5, I see that apps can be placed (via Settings) either "In Notification Center" or "Not In Notification Center." I haven't found anything in the new documentation so far, but I'm hoping there is a way to have my app "In Notification Center" by default, (and possibly even set Sounds active and the notification type to Alert) which would save me having to explicitly explain to new users that after they download & install my app, they will have to manually go and elect for the app to be "In Notification Center."
Anyone know if this is possible? Seems that since an app can register a local notification, it should be able to receive it, by default (whether it displays an alert or an item in the new Notification Center, or not). Thanks in advance.
I've encountered the same problem. The only clue I saw in documentation is that the new Notification Center handles both local and remote notifications. Therefor I assumed that the app should register for local as it would for remote notification. Added this piece of code -
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
and after my app scheduled a local notification it appeared at the "In Notification Center".
BUT it seems to have no affect if my app already appears in "Not In Notification Center".. So have all of my customers that ran the app before the next update got screwed?
Currently it seems not.
I'm in a similar situation. I'd love to be wrong about this but I've found no mention of any such API (for specifying that a local-notification using app should appear in notification center by default) in any of the places I'd expect it to be:
Local and Push Notification guide
UIApplication class reference
UIKit Info PList keys
UIApplicationDelegate Protocol reference