I’ve been looking to see if anyone had a solution for this but cant find one. I would like to receive the notification that the iOS App is about to go to the background (user has pressed home or launched a URL) and/or that it is about to enter the foreground (so I can implement a pin lock type function!).
These notifications are available in UIApplicationDelegate according to the XCode Docs:
Can these event notifications be added with declares (and if so how?) or would this be something which only Xojo can add as ‘official’ app events?
Many thanks in advance …
Aha! Great! - thanks Jason. I will give it a try …
Jason, you are the man! Works a dream!
FYI - I had to grab the latest Foundation Library and UIKit declares from your main project to get it to build (I was getting Ptr/UInt32 errors) so you might want to update your example project at some time …
I can send you the one I modified if you wish - won’t post it here now as its obviously your code not mine
Thanks again, Y
I’m glad it worked for you and that you were able to find the working Foundation classes! I’ve been meaning to add it into iOSKit itself for quite some time but I haven’t had the time to do so. That project is very old so it’s not surprising there were errors with the core classes since there was a large round of updates that happened since I posted the project to deal with changes in Xojo.
Yes I guessed as much
If you do get a chance to look at the project, you could maybe fix one small thing thing as I got over-excited and tried to use the notifications which were also in there …
You can register for both types of notifications, these methods work perfectly.
Triggering a local notification immediately works.
BUT … when calling the method to register for a notification in 1 minute it bombs immediately in the simulator. On an actual device it bombs about 50% of the time but sometimes works perfectly.
I would love to use this if it worked …!
Would you be able to privately send me the logs for when it crashes? I tested them fairly extensively on my phone and everything worked.
Sure - will do that , might need your help on what to log!
[quote=284856:@Jason King]See if this does the trick:
I tried to add that to my app, and got 15 different errors.
It is such a pity that Xojo did not add these events by default. Deep sigh.
45594 - ios : Please add activate / deactivate to App
Michel Bujardet Today at 7:28 PM
See Activate/Deactivate event doesn't fire - iOS - Xojo Programming Forum
and iOS events for going to and returning from background ... - iOS - Xojo Programming Forum
Please add Activate/Deactivate to App.
What errors do you see? For me, the example project works exactly as expected and compiles just fine in 2016r3. Maybe you have some missing/duplicated dependencies which need to be corrected.
The demo project works perfectly.
It is indeed probably interferences with other libraries. It is not your fault. My current project looks like a christmas tree, with plenty of classes and stuff hanging around, to alleviate the incredible number of things missing in Xojo iOS.
If Xojo condescended to satisfy even 10% of feature requests asking for very basic things that have been in Desktop for 25 years, their toyish platform would become decent at last.
I did not really need it for this project. I will save everything as I go, instead of once when the app resigns.
What other libraries are you using? iOSKit and iOSLib should be compatible. The only thing I can think of being a problem would be dtPlugins classes if they expose the same constants/class names. I’m just trying to understand what might be incompatible so it is no longer a problem.
I neither use iOSKit or iOSLib. Beardslee’s gestures, dtPlugins, and my wrapper.
I will try to see what is conflicting.
It seemed to be an incompatibility with iOSGestures. So I removed it, and dragged the classes and modules from your project.
At that moment, apparently the regular App object was no longer seen, and errors all concerned properties and constants of my project App object. For instance, such things as
Type "improvediOSApplication" has no member named "Identifier"
Yet, I had not set App’s super as ImprovediOSApplication. When I did, it made no difference.
For the time being, I cannot use iOSImprovedApplication. Sorry.
I have come back to the improvediOSApplication project.
It took me a while, but I corrected all redundant declarations, some missing declares, and now it works as expected.
Thank you Jason