Fetch from background - iphone

I am writing an iPhone app, and I have a remote server that will deliver content. I would like to have my app poll the server once per day to see if there is new content, even if it's not running or in the background. I would also like to do this without setting up an APNS. Any advice?

You can't do that, either when your 'not' running or if you are running in the background. The best you could do is to download once per day when your app is first run / pushed to the foreground.
You could use remote notifications to "prompt" the user to bring the app to the foreground so that it could download something?
With the current apple IOS guidelines, that is about the best you can do.

I read that you are trying to avoid using APNS, but I am wondering if you are trying to avoid it for the right reasons, especially when it is designed to efficiently solve the scenario you are describing. I've seen many developers seek alternative solutions to APNS simply because the technology appeared to be complex to use after looking at Apple's documentation. The online documentation does go into a lot of details, right down to the binary protocol level.
But just to be sure you know, there are open-source libraries whose only purpose is to shield you from all these technical details. Some libraries are more complex than others, but some are remarkably user-friendly. If you have not done so already, you might like to take a look at JavaPNS and other similar projects.

Related

Interprocess communication between iPhone apps

I need to implement a communication between a central app that runs always and other apps that may request services from that app. There should also be a way to communicate back to those requests even if they have been closed (i.e. loading them to get the responds). What is the best way to implement that on iPhone? (on Android a solution could be done using StartActivity)
Thanks
On the same device? Impossible with official APIs.
If jailbreaking is an option, try the CPDistributedMessagingCenter class. It has a very good documentation on the iPhone Dev Wiki (just google it). You may also want to look at how I used it one of my tweaks: see the daemon's implementation on GitHub.

Is there a delay after which crash logs of an app are visible on iTunes Connect?

One of my apps is in the appstore and I got a call from one of our clients saying a specific feature in the application is consitently causing the app to crash. However, I don't see any logs in iTunes Connect rightnow. Is there a delay between the app crashing and the log being submitted? If so, how long does it usually take?
Thanks,
Teja.
You'd be better asking them to send you crash reports directly. If they sync their handset using iTunes there will be a copy on their PC/Mac.
Unfortunately it seems that people are syncing their phones less and less often. (Which means they never make it into iTC.) Also, not all of them make it into iTC. Apple aggregate them but there also appears to be some level of filtering. What they do is not documented.
This blog explains what I ended up doing with my apps.
You should use a service like Crittercism - They give you real-time crash reports. You could also use something open-source like PLCrashReporter if you want to implement the server yourself.
The delay really depends on how long it takes before the user syncs their device with iTunes. I believe after that it's pretty quick.
Also it's worth noting that iTunes Connect needs a few crash reports before it displays them.

Scheduling iPhone application execution

I'm writing an iPhone app for a client, and they have requested a feature whereby the app "wakes up" at certain times during the day to display a message to the user.
I'm well aware that I can't have the application run in the background and simply move to the foreground at the appropriate time (short of requiring jailbreaking, which isn't really an option for a commercial app). What I'd ideally like would be to simply have the system schedule the application to be run at a particular time of day.
As far as I can tell, the only way to achieve this seems to be to implement push notifications and have a server send the app a message at the appropriate time of day. But this is really ugly and undesirable for several reasons:
It requires a constant internet connection on the user's phone (something that I can't really assume)
It places a large burden on the server in having to keep track of these times (which may be different for each user)
Its just a generally crappy workaround - that's not what push messages are designed for, a dedicated scheduler seems like a much better option.
Does anyone know of a better alternative?
Currently, this is the only option. File a bug with Apple requesting 'local notifications' (a term I've heard their engineers use in relation to this problem.) Ideally, they would work just as push notifications work now, but not require any net connection. Sorry!
Now you can use local notification instead of push notification. Available in iOS 4.0.

iPhone gui message from perl/shell-script possible?

I want to write a perlscript on my iPhone that is able to give me a heads up at certain points so I'm wondering how I would go about doing that.
Is there a way to get a message through the gui from a script running in the background? I've been looking without much luck. I had a thought about inserting a fake sms into the sqlite db as a last resort but it seems somewhat unlikely that it would work.
It would be nice to be able to make a push notification style popup appear but that might too much to ask.
Any ideas?
For reasons of security and stability, Apple does not allow scripting languages on the iPhone. You can run them on a jailbroken phone but I'm given to understand it's a hassle.
From the Apple Push Notification Programming Guide:
Note: On a desktop system, a
background process is often the means
whereby users are informed of
downloadable data for an application
that currently isn’t running. But on a
device such as the iPhone, background
applications are, for performance and
security reasons, prohibited. Only one
application may be executing at a
time.
The iPhone is a secure and reliable phone first and a computer second. Computing is sacrificed to ensure a reliable phone.
I found a solution I liked so I decided to share it. I found an app for jailbroken iPhones called GriP - Growl for iPhone. Which changes the way push notifications and other messages are handled. It also makes it possible to send messages from the command line via something along the lines of:
/usr/bin/GriP -t "Title" -d "Description"
It has worked great so far.
Thank you for your help TechZen and molecules.
Do you want information from your phone itself or from an outside source? If you want information from an outside source, you could set up a Perl script on a computer to e-mail yourself notifications (see Sending Email with Perl Best Practice).

What is the iPhone SDK Missing?

I've been doing mobile app development for a long time (2001?), but the systems we worked with back then were dedicated mobile development environments (Symbian, J2ME, BREW). iPhone SDK is a curious hybrid of Mac OS X and Apple's take on mobile (Cocoa Touch).
But it is missing some stuff that other mobile systems have, IMO. Specifically:
Application background processing
SMS/MMS application routing (send an SMS to my application in the background)
API for accessing phone functions/call history/call interception
I realize that Apple has perfectly valid reasons for releasing the SDK the way they did. I am curious what people on SO think the SDK is missing and how would they go about fixing/adding it, were they an Engineering Product Manager at Apple.
The biggest shortcoming in my opinion is support for separating licensing from distribution.
What I mean by this is that it should be possible to download a trial version of an application and later purchase a license for that application (from an API call inside the application or from the app store). This would make it much easier to try-before-you-buy and get rid of the current duplicates of many applications with 'lite' versions.
I think lack of push notifications for apps is the big thing we're missing right now. With push, you can register your application to perform a task (like getting the most recent data from a web service) even when it's not running, at a time and frequency the OS decides is best. In an ideal world, along with the existing concept of iPhone apps loading quickly and resuming where you last left off, this solves the problem of not running in the background. I know some tasks will be more difficult or maybe impossible with this strategy, but it's still a pretty good compromise between third party applications and the iPhone's limited hardware.
Originally push was scheduled for last September, but it was removed from the beta SDK and not spoken of since then.
API's I'm personally looking for:
Apple80211 as a public API (private, current API is fine if documented)
Access to Volume buttons (semi-accessible via Celestial, private, needs new API)
Access to Calendar (private, API status unknown)
Access to Bluetooth + SPP profile (status unknown)
Access to Camera (directly, API status unknown)
Access to JavaScript runtime (directly, not through UIWebView, API status unknown)
WebKit access that's lower-level than UIWebView (private, current API is fine)
Access to Music Library (private, current API is fine)
Garbage Collection.
CoreData is missing.
You've mentioned some of the big ones - copy & paste (or in fact any way for apps to collaborate) is another huge omission.
It also seems to lack a desktop synch framework (at least if it exists I can't find it).
Language independence and especially lack of scripting is another pet peeve - objective-c is all very well but more languages to choose from would be good.
Inability to dynamically extend apps, via scripts or otherwise, is another big omission. This is partly an SDK/OS issue, partly licensing.
My list ordered by priority:
Mapping abstraction (the MapKit looks awesome), but that would require a new Google Maps TOS
Music library
Camera (photo + video) Access to more
UIViews, Apple designed some pretty nice custom ones for their apps
Better UIWebKit abstraction
The features I see missing that it should have is
Access to SMS
Direct Access to Google Maps App. You should be able have access to this so you could extend your application to use the built in features provided by Google Maps.
Access to the Bluetooth functionality of the phone.
Access to the Calendar. Why not allow access to simply post a calendar event for the user.
Access to Active Sync. It would great if we could directly access this and communicate back to the Exchange Server.
Core Image. They provide Core Animation but Core Image is missing. I hope that this is added to the API soon.
These are some of the features that my clients have access for in the past and are supprised when they are not available.
We definitely miss a Calendar API and SMS access. So many applications could leverage such APIs. The iPhone allows users to have everything in their pocket, but it's almost useless as long as developers cannot leverage this integration in their apps.
A language with proper namespaces.
A limitation that bugs me is lack of access to system features that require root or setuid. For example: opening privileged IP ports.
I'm not sure there is a good solution to this, as long as Apple's policy is to keep the device locked-down.
Allow program to set some kind of local timed event for your application to bring up an alert and launch your app if the user agrees (like any calendar app). You could do that with push notifications but there are many cases I'd hate to have to rely on a whole server infrastructure and network connectivity just to basically do some timed thing.
Some idea of what direction the user is facing. I cannot believe the GPS chip the newer iPhones use are not capable of reporting direction.
I would personally love to see
Access to the CoreTelephony Framework (Currently private). Which allows access to all the phone functions (Especially sending MMS / SMS).
Some sort of ability to run stuff in the background. While push notifications is ok for most things, but it is a bit hard to leverage CoreLocation (i.e. have the app show a notification at a certain location). Of course this would probably need an on/off button or app specific like push is.
animation view which will be reduce developer to make a cool app , of course the core business local still need consider more , but the view layer could more easy to use ....