WatchOS app keeps crashing when being opened from remote notification - objective-c

WatchOS app works normally if being opened from home screen. If I try to open it from remote notification screen (by tapping title label) two app behaviors can be spotted:
If application was loaded previously (I don't know how to name it, maybe better to tell that app is not killed by system or still present in memory). In this case application will load normally and do some action if asked (for example open some Interface Controller and show remote notification details).
If application was launched long time ago (or killed by system, unloaded from memory, in my case I'm stopping it in Xcode). If app receives remote notification in this state after tapping on title label of notification scene it will try to load for some time and finally crash (this may take 1sec or 1min). Or it will stuck with loading indicator shown - what is interesting that in this case if I'll try to attach watch extension process to Xcode debug it will show that app is launched and works (for example I can send some data from parent iOS app and watchOS app will receive it - triggered method in Extension delegate and do some stuff).
Googling I have found that watch apps can be killed by system if they take to much power when being launched, so I tried to remove any load while app is starting itself but with no success - it still keeps crashing.
The only close to mine situation that I've found so far was a topic in apple developers forum:
https://forums.developer.apple.com/thread/20553
I have been spotting the same logs like in topic when watching how watch app behave in Xcode/Devices, but after updating to WatchOS 3 (now 3.1 beta) and using new Xcode 8 (now 8.1 beta) I can't see any logs from WatchOS at all (just some system messages that watch screen was turned of and on).
Have any one spotted such issues while working with watchOS remote notifications? Any suggestion where to search for solution?

Related

Titanium iOS auto restart application in background once swiped off from background

I am working in an application that detects any Beacons nearby and gives and alert in the form of local notifications for iOS. I used TiBeacons library for titanium which did the work but I am right now stuck with an issue where I need to keep the Application running even when the user swipes off the application from background.
I was able to make it work in background which is the paused state,but is it possible to make it restart itself in the background when the user swipes the app from the background processes running,maybe with a delay if not promptly?? Thanks
There is no way to restart application after user removed it from a memory. This would be huge security bridge allowing developers to do lots of evil things to customers' devices.
You can run your code only when app is in foreground and background but never when it's killed.
You can try activate your app by receiving notification from Apple Notification Center Service:
The purpose of the Apple Notification Center Service (ANCS) is to give Bluetooth accessories (that connect to iOS devices through a Bluetooth low-energy link) a simple and convenient way to access many kinds of notifications that are generated on iOS devices.
The ability to detect iBeacons after the app was killed in the task switcher was only added in iOS 7.1. Also, I believe this functionality requires that beacon monitoring be set up with the app's main AppDelegate object as the CoreLocation delegate. I do not know much about Titanium, but glancing at the source, it appears it does not do this, and instead uses a different class as the CoreLocation delegate. This may explain why this does not work for you.
If my suspicion is true, you would not be able to detect after the app is killed using an unmodified version of that library.
Since I am not a Titanium expert, it would be best if someone who knows more about it could confirm or refute my suspicion.

Can an iBeacon notify a user's iphone without an app being installed?

I'm new to iBeacon's and am trying to understand one simple thing.
Can I use iBeacon to display a notification on a user's iphone without a custom app being installed?
For example, I'd like to build an app that sends out iBeacon messages to people that have an iPhone. When they get near an iPad running my app, it notifies them that they're near my "event", which of course is taking place at the location of my iPad.
Is this possible without the user having already installed another app that I've made to receive notifications of my event?
Note that I'm open to any other tech or ideas that would make this work. I know that Apple does this with their Apple Stores, but I'm guessing they can do this because they already have an app installed on the users device - probably the "AppStore" app.
You typically need an app for any iOS notifications on seeing an iBeacon. That is what Apple does for their stores.
The only exception is if you use Passbook to set up a notification trigger. But you still need the user to install your Passbook entry.

My iOS App Terminated due to Memory Pressure when I am using Photos.app

I am running my application on iOS 7.0.1 & iPod Touch 5th generation device. When I follow below steps my app quits with below error on Xcode 5 without any error in console
App quit Unexpectedly Terminated due to Memory Pressure
Steps:
1) Run my application using Xcode 5. Login & then go to Home
2) Click on Home button so that my app enters in background (I can see my app is in background)
3) Start inbuilt Photos app from iOS. Click 1 or 2 pictures
4) After taking 1-2 pictures , App quit Unexpectedly Terminated due to Memory Pressure
I am not doing anything in my app. When I checked the CPU usage its 0% & Memeory used = 15.2 MB
Also there is no other app running in the background except my app.
Can anybody help with this ? Thanks
I am not getting why this is happening. If I don't use Photos.app then app works smoothly.
There's nothing you can, or should, do about this. You application is no longer in the foreground, and the foreground app (photos) is asking for more memory. To supply this, iOS will terminate any apps running in the background. It doesn't matter how much memory your app is using, iOS will terminate background apps as long as the foreground app requires more memory.
Once your app enters the background you can expect it to be terminated at any time. To improve the user experience, you can look at Enabling State Preservation and Restoration in Your App. This in theory allows your app to start where it left off when the user comes back to it.

ios launch appstore from within my app causes my app to terminate

I'm trying to take users of My App to the AppStore for several different functions - like Upgrade to Full Version, Rate/Review or simply View another App I've developed. However, all of these are causing my App to Terminate when iTunes is launched on the device. I'm using some simple code and
have tried many combinations of URLs, all of which successfully get to where they are going. Here are the behaviors:
User clicks Rate App
Code directs them to the web via:
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:[[MyApp defaultApp] itunesLink]]];
My App goes to the background, and my delegate's applicationDidEnterBackground is called successfully
As iTunes is coming up, my App is terminated. Happens whether I run via X-Code or on the device directly.
When I quit out of the store and look at the running processes on the device, my App is still shown there. I know it has been terminated from X-Code console, and when I try to restart it it starts fresh.
I've tried the itunesLink as either itms://itunes.apple.com/app/ or with http - all of which get to the correct end point. If I use www.google.com it works fine and my App is NOT terminated, just sent to the background and the website is displayed OK.
Other points are that when I run via the simulator, the openURL call returns failure and doesn't open any URL.
Any insights as to why my App would be terminating? It's acting like an iOS security feature or something which is shutting my App down, but I thought what I was doing was pretty standard stuff.
If anyone has seen anything similar, I'd really appreciate advice on the situation.
Your app could be terminated for a number of reasons. The best thing is to look at the device console using Xcode's Organizer:
Your app may simply be terminated as a result of low memory notifications. As soon as it moves to the background and the app store launches (iTunes and the app store both use plenty of memory) it can be killed to free up memory. In this case you will set messages from "jetsam" like this:
<Notice>: jetsam: kernel termination snapshot being created
<Warning>: Application 'UIKitApplication:com.yourapp[0x6337]' exited abnormally with signal 9: Killed: 9
You should use the Activity Monitor in Instruments to see how much memory your application is using. iOS will terminate the most memory-intensive applications first, so you should try to reduce your app's memory footprint.

Function 'didFinishLaunchingWithOptions' getting invoked inappropriately

I am using cordova 2.1.0 for my IOS app development.
I connected my IOS device to a MAC processor and installed/initialized my app running in xcode or dragged it from itunes folder. Now i physically disconnected my device from the processor and through wifi enabled in the device, sent notifications/messages through APNS to the device. I was able to successfully receive notifications in the device. Now after some time, i reconnected the device to the processor, which lead to a problem of the app launching again and calling 'didFinishLaunchingWithOptions' method again, which is not desirable as the launch/initialization should happen only once. This behaviour is random ie. every time when i disconnect/reconnect, it is not happening, only sometimes. Why is this happening. What could be the reason for this random behaviour.
Any help will be appreciated.Thanks
didFinishLaunchingWithOptions: is called every time the app is launched. When you run your app from Xcode, and disconnect the device, it kills the app. So, when you launch the app with the device disconnected, it starts the app again, which calls didFinishLaunchingWithOptions: when the app finishes launching. The same thing happens if you run the app from Xcode, and run it again the same way.
EDIT :
Not sure if it's clear, but didFinishLaunchingWithOptions: is not called if you quit the app (press the home button) and call it back without killing it.