watchOS application is not opening in background after scheduling - watch

Apple Watch Series 3 watchOS 4.x.x, iPhone 6 iOS 11.x.x, Xcode 9.2
I downloaded the code from the following link:
SOURCE CODE
Then able to install and run this swift application on my apple watch.
As per code, I tapped "Schedule Refresh" button and put my app in background by pressing crown button. Then app was not opening in background for making server call.
I was expecting, following function will be called, but not
func handle(_ backgroundTasks: Set<WKRefreshBackgroundTask>) { }
So, please let me know if anyone tried this sample app to run watch application in background.

Related

Local User Notification action tapped on watch not delivered to iOS app

I have an iOS 10 app and watchOS 3 extension that uses iOS 10 User Notifications Framework. The local notification is scheduled from the iOS app, and is shown on the watch when the iPhone is locked, and shown on the iOS app on the lock screen if I raise my iPhone, and don't respond to the watch. The iOS notification have three background action buttons.
If I respond to the notification on my iPhone, the userNotificationCenter(_:didReceive:withCompletionHandler:) UNUserNotificationCenter delegate method is called correctly. But if I instead tap on one of the action buttons on my watch, the function is not called.
According to Apple's App Programming Guide for watchOS, under the section Responding to Selected Actions:
For background actions, the handling of actions depends on where the notification was scheduled:For local notifications scheduled on iPhone, background actions are handled by your iOS app regardless of which device displayed the notification.
This is not happening, and I don't know why. Have anyone got this working from the watchOS?
It looks like I didn't put the correct options in the UNNotificationAction. The options should be an empty array, instead of the .foreground I had mistakenly put there.
So for e.g. the Just Practice button, the correct action for it to be background is:
let justPracticeAction = UNNotificationAction(identifier: "justPractice", title: "Just Practice", options: [])

Debugging in XCode is not forcing a rebuild

I am learning XCode with Swift by writing a basic iPhone app. I run the app in the simulator by pressing the 'play' button. However, when I change the code and then click play (without shutting down the simulator), I don't think the latest app code gets executed in the simulator. Any advice as to what's happening?

monotouch iphone programmatically go to phone home screen

I searched a lot and didn't find how to programmatically bring application to background so phone's home screen is shown. I don't want to terminate app, but just to programmatically make press on HOME button. Is there any way to do it?
No, unfortunately not. There is no public API that allows you to send a user back to the homescreen.
As shown in these questions:
iPhone - Sending the app to the background
Send App to Background process
Sending Application to background on iphone
Programmatically sending an iOS app to background
Brad Larson provides a detailed explanation to the answer of this question:
Suspend the application
Unfortunately, there is no background mode in iOS where the app can still run things while out of focus. Apple has designed the system to "pause" the application so state is preserved, but be careful the app can be terminated at any time.
You can do this by calling a private API but beware as said above Apple does not allow this on AppStore apps.
var x = UIApplication.SharedApplication;
x.PerformSelector (sel: new MonoTouch.ObjCRuntime.Selector ("suspend"), obj: x, delay: 5);

App crashes when closed

When I close my app (double tap home button and touch the X) on my iPhone, it crashes and I get this error:
objc[9337]: class `ADManager' not linked into application
objc[9337]: class `ADSessionManager' not linked into application
objc[9337]: class `ADSession' not linked into application
(lldb)
-Deployment target: iOS 5.1
-Iphone iOS 5.1.1
-Testing with Xcode on iPhone
How can I fix it?
This is the default behavior of all iOS apps in iOS4 and later.
Um, it's not a good idea to be running the app connected to Xcode debugger and then terminate it in the middle of the process. It can very easily lead to the bootstrap error.
The debugger is constantly monitoring your app when you run it in iTunes, terminating it would obviously cause a crash =/
You can see a spinning icon in the "debug" tab in Xcode 4 (the tab with the icon that looks like a speech button and some lines in it in your project navigator) when you're in the middle of debugging.
Not sure what you're trying to achieve by terminating your app, a registered background process such as location service?

iphone ios application home button press/applicationDidEnterBackground crash

hallo, i am newbie in developing iphne/ios application and i have
encountered some problem
generrraly my app (which is iphone camera image processing app) has no
visible errors at today stage except the one
when i press the home button to send my app off screen (putting to the
background), and then press the app icon to 'wake it up' again
it crashes
what would it be...? what the reason of it would be?
what is done to my app (seen from the view of programmer
- i mean internal game state) by this home buton operation?
- what i should take care of before "applicationDidEnterBackground"
eventually?
thanx for answer
Is this happening when you are running it from Xcode? Xcode does not like it if you hit the home button and start it again from within the device/simulator. Is it crashing if you launch it from the device (or simulator) without Xcode running? If not, then there probably isn't a problem.