HealthKit & Today Extensions/Widgets - ios

Has anyone combined these two new features in iOS8 yet? I'm attempting to access HealthKit from a widget. But since the application and extension use two separate App IDs - the widget automatically rejects access to HealthKit. The Notification Center/Today view doesn't display any prompt to allow access. I notice it attempts to because I see an "unbalanced view controller transition" warning in the console, but nothing is displayed.
For a manual fix - the Health app will display the bundle ID with permissions that can be manually changed. However, there's no app icon and the extension is listed as its bundle ID and not listed as its product name. This makes me think this is still something they are working on in the beta.

You could try to access the HealthKit data from your containing app and then share those data with your extension through App Group.
I haven't looked at HealthKit yet, but in another case the App Group feature worked fine for me.

I haven't tried doing this type of combination between those features in my app yet, but while integrating the HealthKit capabilities, I happened to see the following in HealthKit documentations:
Both HealthKit and the Health app are unavailable on iPad. The HealthKit framework cannot be used in an app extension
So I assume a direct way is not available... You can read more here: HealthKit_Framework Documentation

You won't be able to access HealthKit. To quote Apple's App Extension Programming Guide:
Some APIs Are Unavailable to App Extensions
Because of its focused role in the system, an app extension is ineligible to participate in certain activities. An app extension cannot: …
Use any API marked in header files with the NS_EXTENSION_UNAVAILABLE macro, or similar unavailability macro, or any API in an unavailable framework
For example, in iOS 8.0, the HealthKit framework and EventKit UI framework are unavailable to app extensions.
[emphasis added.]

Related

Role of framework in between Extension and App in ios

I'm bit confused about the concepts of Extension in ios. After going through some tutorials I still have doubt how an app and an extension in ios communicate each other, does this has to do anything with Framework. If Yes, why we are adding Frameworks...
Hoping for a response, Thanks
App extensions are not stand alone apps. They are providing extended functionality of the app (which can be accessed from main app, called the host app) that is meant to be efficient and focused towards a single task.
For example, Today widget in iPhone is an extension. We can create a today widget for an iOS app which is an extension of the existing iOS app. For example, let us consider an app which shows current weather in detail. Then you can create an extension for this app, to show only current temperature without much detail in a widget.
The extension uses the data which is shared between both the main app and the extension. Embedded framework is a technique to share same code between two targets. You can share data using NSUserdefaults and app group concept.

How to pass objects/data between my iOS applications

I have an existing iOS application on the app store, and I am building a new companion app to work with this existing app.
I need to pass objects/data from this new app to my existing app when a certain action is taken. The behaviour I'm looking for is very similar to AirDrop but the data is passed to another app on the same device.
The objects I want to pass locally between apps are simply NSObject's.
As per your comment you wants to share NSObjects between your iOS apps. The best approach would be "Custom URL Schemes". But in this approach you may need to add or re write some parts in your old iOS App as well.
checkout this SO Answer for more info on implementing custom url scheme and history of sharing data between ios apps.
Apple documentation for sharing data is also available.
If your app supports greater than iOS 8 you can also use the new feature called "App Group Functionality"

How to call a method in the parent iPhone app from Today Extension in Swift?

I have just created an Apple Watch extension to my iPhone App and used the following method to update my app data.
// Call the parent application which launches a method to update the app data
WatchViewController.openParentApplication([:],
reply: { (reply, error) -> Void in
self.updateGui() // update the gui when done
})
Is there anything similar for Apple Today Extensions (widgets)? It feels wrong to implement all the client-server communication again for the extension.
Or how do you suggest to update my data (stored in app group throughout iPhone app, WatchKit and Today Extension).
No need to write client-server communication code separate for container app and its extension.
Apple recommends embedded frameworks for the same. You create an embedded framework which can be used across both targets. Place code that will need to be used by both the container app and extension in the framework to avoid code repetition.
And for sharing data between container app and extension, you can use NSUserDefaults through AppGroup.
Please check Apple documentation.

App Groups and iCloud in iOS

I am familiar with iCloud syncing, but I am new to app groups. There may be a simple answer to this question, but I haven't found it yet. Basically, I have an app in which I have iCloud integration, and now I want to try to add a today extension. I am currently using Core Data as a backend and would like to continue to do so. However, from what I have read, I need to move my data store to a shared location by defining an "App Group". (http://blog.sam-oakley.co.uk/post/92323630293/sharing-core-data-between-app-and-extension-in-ios-8 and Accessing Core Data SQL Database in iOS 8 Extension (Sharing Data Between App and Widget Extension)) I haven't been able to find out if this location is synced using iCloud or not. Or, because I"m using iCloud, do I need an App Group at all? I appreciate any and all help/suggestions.
If you're already using iCloud, you don't need to use app groups, because your extension can access the same iCloud container as your app does. As long as your entitlements and provisioning are configured correctly, you can literally just use the same Core Data stack setup in the extension as in the app.
Apple's Lister demo project does this, but there's nothing special about it. Just use iCloud as usual.
App groups are usually necessary to share data between apps and extensions. But a big exception is when the data is already stored external to the app-- as with iCloud.

MoPub Full SDK 2.3.0 Improper IDFA usage

During my IOS app validation, warning shows "Improper Advertising Identifier [IDFA] Usage. Your app contains the IDFA API but you have not indicated its usage on the Prepare for Upload". I have updated the admob SDK inside with the latest. Do I have to tick using IDFA during the preparation for upload?
Regards
Hammer
Yes, if you are using the Ad Identifier in your own code or in third party libraries such as mopub, then Apple requires you to fill in and check the appropriate forms on the IDFA questionnaire prior to upload.
Specifically, the section advises app developers that the IDFA is “the only way to offer targeted ads” and offers three use cases which they must also check, if in place:
Serve advertisements within the app
Attribute this app installation to a previously served advertisement
Attribute an action taken within this app to a previously served advertisement
Source

Resources