Is there a method being called when a user removes my app from iphone - iphone

I would like to know if there is a way to know if a user removes my app from his iphone (permanently).
(I would like to handle this kind of event in order to remove it from my DB on my server)
Thank you.

Simple Answer. No. Your best option is to check for inactivity for x amount of time and assume that means it's deleted.

Related

Prefetching some data when the App is in the background

I know quite a few questions have been asked around this topic; however, am penning this as they don't seem to specifically answer my question, & some don't have any correct answer listed.
What I want to do in my iPhone App
Fetch some data when the App is not running (basically, it's a prefetch, so as to quicken it when the user uses the App the next time). What's the best way to do this?
Some Potential Solutions
Those that I could think of & some from Stackoverflow & such resources:
Possibility 1 : Fetch the data at a specific time of the day (maybe after midnight ?). Am not seeing 'clearly' how to do this if this this possible in the first place. Some suggest using a NSTimer -> but the timer is put off when the application is suspended, right?
Possibility 2 : Using local notification (?) But I see that Apple's documentation specifically mentioning that notification is to be used to convey something to the user & so this would defy Apple's doc then, right?
Possibility 3 : Through applicationDidEnterBackground -> beginBackgroundTaskWithExpirationHandler . This wouldn't run the fetch at a specific time of the day though. However, it might serve its purpose of 'pre'-fetching. Is this better than the other two?
Any thoughts please?
as you already know that none of the option you have presented are not going to work with ios and user can always close the background applications anyway so I would suggest that it'd be a good idea to fetch the data for next calendar day whenever the app is running.
As samfisher is saying none of your specs. fit with the Apple active background requirements. The only thing that I can suggest you is to use the beginBackgroundTaskWithExpirationHandler I understand that is a "post fetching" instead of prefetching but I guess is the only way.
The other way, but is a little bit trickier, is masquerade your prefetching with some sort of geolocation, in this way you could opt for an active background. This involve a lot of aspects such as:
Appstore rejection
Battery consumption
There are plenty of app on the appstore that use this trick, I can remember one that calculate data traffic.

Implementing a persistent clock

I'm currently working on a new game for iOS using Cocos2D. The game needs to advance states after x amount of time since the first launch. So for example:
State - Time
initial launch
24hrs
48hrs
My first idea was to just get the data and time on first launch and save it to a file. Then I could check it ever now and again to see how much time has passed. The problem with this is I need it to be in realtime so that the changes will take effect immediately once the state is reached. It also needs to continue when the user is not using the app. The functionality I'm looking for is kind of similar to how the iOS strategy games work where you build structures that take x amount of time.
Anyway my question(s) is; is there some sort of library that can accomplish this and how can I get it to continue after the user exits the app?
It can't. There is - apart from kind of misusing video/music playing etc. no way for your app to do work while it is not running.
You have two things you can do to simulate that behavior (and I suppose the strategy games do this, too):
You can calculate at any time while a user is still running your app the points in the future when something should happen (eg a housing structure is finished). When the user leave your app, store these future times as local events - then the user will get notified that something has happened in your game (eg message "The church has been built. Do you want to go to church now?)". Pressing yes will open your app, and you can do whatever is necessary to indeed build the church. So in fact you don't do it at the time when it occurred, but when the user opens your app the next time.
Like 1, but without notification. Just remember when the user leaves the app (eg in your settings, I would use a property list; set it when the app delegate gets the appWillResignActive event), and the next time he starts do whatever would have been done in the meantime - he won't be able to tell the difference :-).
It's all about make believe here :-).

Send notification each day with different information

i want to send a notification each day at the same time with different information. I got no problem with showing the alert when i want to. The problem is what to show. First i tried to schedule one alert every day with different information in them, but that seems really inefficient. Then i tried with
-(void)application(UIApplication*)app didReceiveLocalNotification:(UILocalNotification *)Notif{}
but found out that it runs when the application is running in foreground only.
Is there any way to provide an array or something like it with the alert and tell the alert to get its body from the array with different index for different days?
Or should i do it with some notification that can run when the app is in background mode and the alert show and make a new alert?
All information must be provided when you schedule a local notification, so no, a notification's body cannot be sourced from an array as you described. If users are likely to open your app often and you know notification content in advance, perhaps you could ensure that x notifications are always scheduled (could be achieved by inspecting UIApplication's scheduledLocalNotifications).
This solution isn't ideal though, as it relies on users opening your app on a (somewhat) regular basis. I think push notifications are probably your best bet, but that requires access to a server, etc.
Yeah push could prob be the solution. But i dont have a server for that. The users will most likeley not open it any more after they have opened it the first time to activite the local-messages. So then this isnt really possible to do without push. when i tried a for-loop to schedule 250 days with different text each day it took about 2 minutes on iphone 4 so its not duable.

How would I get SMS/Phone events, and act on them before they're sent to the system apps?

I'm trying to develop an application for a jailbroken iPhone similar to Mcleaner or iBlacklist.
What I want my app to be able to do is intercept SMS or Phone events and handle them before they're sent to the appropriate receiver. So for example, I want the application to get an SMS event, compare the sender to an array of numbers, and either process the data or ignore it and pass it off to the SMS app.
In MCleaner, you can define a blacklist of numbers, and if a text message is received that matches the blacklist the user won't get an alert from the phone and the data is instead handled by MCleaner.
How would I go about getting these events, and further, how would I get these before the appropriate apps receive them? From what I understand, I'd need to become a first responder for these things, but I really have no clue where to start. I can't seem to find any hints on how I'd go about this as this app will not be calling apple classes to get the data..
Thanks.
I can only guide in with this, sorry, the code isn't mine to give.
In memory, all the action calls are all just pointers. What you have to do is over ride the pointer to make it point to your own function. Once you do that, you do w/e you want in your function, and then call the default function call. This ensures the integrity of the action calls and allows you to intercept the actions.
You need to use the CKMessage class.
Check this out: http://hexorcist.com/private_frameworks/html/interface_c_k_message.html
and this: http://www.ifans.com/forums/showthread.php?t=232745

Checking incoming call in iphone

I have read about the CoreTelephony class and in this CTClass can check caller and find state of call....
But when and how to use this......
I think my application goes to background when call start..
help please or correct me......
It is not possible with the official SDK. The best that you can do is determine if the user is on a call. You can do this by inspecting the size of the status bar frame.
[UIApplication sharedApplication].statusBarFrame
If your asking if you can track phone calls in the background, you can't in all situations.
If you want to know if, at any point in time, when your running, you can. You can access the 'CTCallCenter' currentCalls property and it will give you the state of the call at that point in time.
If you want to track if a incomming call the cause of your application going to the background, you can use the 'CTCallCenter' callEventHandler property.
Not quite sure what you're trying to accomplish but after the call ends the user should automatically be brought back to the app.
It's not possible to get this information with the current SDK, most likely for privacy reasons. I'd recommend filing a feature request with Apple (http://radar.apple.com) however, I doubt it's something they're likely to include in the future.