Apple watch and iPhone are not connected when the app in phone goes to background - swift

I ran my iPhone app and its watch extension in the simulator. I send messages from phone to watch and vice versa. The messages are sent and received without any issue. But when I send the iPhone app to background, and then a message is sent from watch to iPhone, I continuously get the following log:
[WC] __33-[WCXPCManager onqueue_reconnect]_block_invoke error reconnecting to daemon due to NSXPCConnectionInterrupted
I searched regarding this but did not find any proper solution. Many have posted it as an issue in the betas of Xcode. I am using the latest Xcode 8.1. What could be the proper solution?

Related

nw_socket_get_input_frames [C4:1] recvmsg(fd 35, 9216 bytes) [61: Connection refused]

We're using the Apple's Network.framework and send data between an iOS app and a macOS app using UDP. We use bonjour for discovery. It works great. Until it doesn't...
The problem is that when I stop using the iOS app for like 2-3 minutes (No, I don't quit the app nor do I put it in background. I just don't interact with the UI for this short period of time. Otherwise the iOS app is open and active), the connection stops working. By this I mean I press a button that should send some data to the macOS app but it just stops working and on the macOS Xcode console I see this
The debug log of the macOS app says: 2020-12-01 22:40:40.274638+0100 Our app [10750:497151] [] nwsocketgetinputframes [C4:1] recvmsg(fd 35, 9216 bytes) [61: Connection refused]
What is this and how to heal it? Does the 2-3 min pause as symptom / trigger of the above error message ring some bells?
Maybe the most interesting thing is that when I turn off the wifi on the iOS app the app immediately discovers that the macOS app is gone. And when I turn the wifi back on the iOS app immediately discovers and connects with the macOS app. And yet this doesn't heal the problem. The only thing that does it rebuilding the macOS app in Xcode.

Content push for Newsstand in iOS 7.1 to change magazine cover suddenly not working in existing Newsstand App

We noticed that the silent content push messages that we are sending to update the magazine cover of our Newsstand App suddenly stopped working specifically in iOS 7.1.
I just did some testing sending the content push to the following devices:
iOS-5.1.1 -> push received -> magazine cover updated -> OK
iOS-7.0.6 -> push received -> magazine cover updated -> OK
iOS-7.1 -> push never received -> NOK
However, if I send a push alert message to these devices, all alert messages are correctly received and shown, so I am sure that I am using the correct device tokens.
And this issue is on an existing App live in the App store, never having this issue before and it seems to be specific to iOS 7.1.
This is the content push message we are sending:
$payload = '{
"aps" :
{
"content-available" : 1,
}
}';
Anybody else having the same problems specific in iOS 7.1?
Thx!
I am having that issue also on 7.1 in development. If connected to XCODE we see the method application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler invoked... ONCE we disconnect from Xcode... that method does NOT get called based on reviewing the console.
EDIT :: Today during testing against the sandbox environment with a iPhone on iOS7 7.1 (11D167) the content-available starting working ?? We are getting calls into didReceiveRemoteNotification fetchCompletionHandler: NOW, even when phone is NOT connected to XCode or anything. Even if the Phone is Locked and Application is in the background... which is what we needed and very important.
Really odd... but we did find that the Manual Do Not Disturb was ON.. on this test phone.. not sure how that got on and if that was issue. Make sure that is NOT ON.. otherwise you will not get any remoteNotification calls into your application. We may have gotten off track with the other postings that content-available was broken on ios7.1.
If anyone knows anything else about this, please share.
From https://support.magplus.com/entries/84992596-About-Lower-Issue-Download-Counts-Since-iOS-7:
About Lower Issue Download Counts Since iOS 7
With the release of iOS 7, Apple changed the way Newsstand Push Notifications work, and it is a significant departure from how Newsstand Push Notifications were delivered with iOS 5 and iOS 6. With iOS 7, Apple attempted to change the way these notifications worked, primarily optimizing the mechanism for apps that receive e-mail and Twitter updates and notifications multiple times within a 24-hour period. Part of the problem with iOS 7 is that it is not clearly differentiating Newsstand Push Notifications (which initiate a background download of content) from standard Push Notifications (which just deliver text).
A key change in iOS 7 is that if an app is killed manually by the end user, then the app simply does not receive Newsstand Push Notifications to automatically download new content in the background. Users manually kill an app by bringing up a screen of currently running apps and swiping one up to force it to quit. Apple views this scenario as one where the end user has made a conscious decision that they do not want the app running/performing background operations which consume battery life.
The two unique features of Newsstand Apps as promoted by Apple self in 2011, 2012 and 2013 (in WWDC video's about newsstand) were:
A - background download of new Magazines and
B - changing the cover when a new Magazine is available and showing a badge.
Unfortunately, in the real world situation, since iOS 7, Apple has killed both these features. Content push messages needed for these two features don't work if the user has killed the Newsstand App. Which in real world situation will almost always be the case.
Suppose you have a Magazine that appears monthly. How big is te chance that the user will have your Newsstand App running all the time in the background? I think almost none...
Before iOS 7, this user could be notified via a content push message resulting in a badge and a new cover visible in the Newsstand.
Since iOS7, these features are gone in real world situations.
Result: much lower magazine views and downloads.
Thanks Apple!

Sending notifications from Mac to iPhone/ iPad/ iPod touch

I currently sell a Mac-only productivity tool that uses visual and audio notifications to remind the user of certain events taking place.
I've started planning the iPhone and iPad versions of that Mac program and would like to be able to provide notification services from the Mac to the iPhone, e.g. instead of the Mac playing an audio cue, the iPhone could vibrate, etc.
I have so far done very little iPhone development and I'm not really sure how the various push notification services work. Is this easy enough to do? or is a "challenge".
A few more potentially relevant pieces of information:
there will be a Dropbox-based sync between the iPhone and the Mac versions, so there is also the possibility of "sharing" a file that would prompt some action
it might be acceptable as a first step to not have "background" notifications and require that the iPhone client is running
What authentication issues should I expect to deal with?
You'll need to implement APNs (Apple Push Notification Service) in both your app and your server.
To clarify a few things:
You'll need a server doing those transferring messages job between the user's Mac/PC and their iDevices.
Your server will decide when to push what kind of notification to which user's device.
After that, your server sends a message to Apple's APNs server, which will push that message on your behalf.
It's absolutely OK that your app can be in the background or even closed when the APNs message arrives at the user's device. The user will be guided by the OS to open your app.
If the user has explicitly disabled your app's APNs function in her/his device, or, if the user cancels the APNs alert when it arrives, your app won't be launched if it originally stays in the background or if it hasn't been open yet.
The user will be asked to enable (as you put it, authenticate) your app's APNs function by the OS in her or his device when your app is launched for the first time.
It's not a challenging task for an experienced iOS developer or an experienced PHP developer, since Apple's documents and APIs are pretty straightforward. However, configuration on the server side can be a little tricky.
I believe Stack Overflow already has tons of information on how to enable APNs in iOS apps. All you need to do is be specific in your question and do the search work beforehand.
Hope that helps.

Apple Push Notification Service - notification messages aren't sent to iphone device

I constructed provider code with using C# and it was able to send notification messages to iphone devices successfully. But since yesterday, it hasn't worked. Also it seems to connect APNS successfully and send notification message. Unfortunately, no notification message is received by iphone device. I controlled internet connection and device token of iphone device. What else can I do? Thanks in advance...
I dont have enough rep to comment on the question so typing out answer - Please add more details and I will edit my answer.
Is this in a developer / testing environment and are you using an ad hoc profile to install the application on the iphone devices?
Did you check if the device token has changed and that you are using the new/ correct token in the C# code?
Do provide more details of your problem.
Crazywood, I don't have a solid answer for you but I can tell you I'm in the same boat as you.
There are times when all my notifications go through and times when none of them seem to.
One guess is that not all notifications are sent. According to the docs, in production remote notifications are not guaranteed to be received by the client. My guess is that this is also the case for the sandbox.
-------- EDIT ------
I went through the trouble shooting list (http://developer.apple.com/library/ios/#technotes/tn2010/tn2265.html) and came across this:
The device may have lost its persistent connection to the push service and can't reconnect. Try quitting the app and relaunching it to see if registration completes the next time. (On iOS 4 and later on devices that support multitasking, you will need to force quit the app from the recents list.) If the registration does not complete, iOS has been unable to re-establish the persistent connection. You can troubleshoot this as described in the previous two sections.
I restarted the app and it made no difference. Then I rebooted my phone. That seemed to do the trick.

Unexpected error while trying to connect to iPhone

Your mobile device has encountered an unexpected error(0xE800002E)
Try disconnecting and powering off the device;then power the device on and reconnect it.
I received these message so many times. How can I fix it?
Although you can see this error when you connect in XCode, it is not actually an Xcode defect.
See this thread at Apple's discussion boards. You basically need to reset you phone. I'm not sure but Ithink there may be a link between seeing this error and using your phone for development but I have no concrete evidence.
I find that if I plug my device in and its set to automatically run iPhoto - then you must let iPhoto load and let it try to sync photos before you quit it. Then you should be able to use XCode to load an application on to your phone.
If you do get the error - unplug the device, turn it off and then back on, and that usually clears up the problem