Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-14617] iOS 7 : Backgrounding Features #4936

Merged
merged 20 commits into from Nov 14, 2013

Conversation

srahim
Copy link
Contributor

@srahim srahim commented Nov 8, 2013

Introduces following new events

New Ti.App.iOS level Events

  • backgroundfetch
  • silentpush
  • backgroundtransfer
  • downloadprogress
  • uploadprogress
  • downloadcompleted
  • sessioneventscompleted
  • sessioncompleted

New Ti.App.iOS methods

  • setMinimumBackgroundFetchInterval(fetchinterval);
  • endBackgroundHandler();

TESTING INSTRUCTIONS

** There are 3 cases to be tested for urlSession
Use the following app.js for all cases mentioned below.
Be sure to include the module to your project.

1. Foreground downloading
* User initiates a background download while in the foreground. The download completes while in the foreground itself.

Instructions.

  • Create a app with the above provided app.js.
  • When the app starts click on the download button. and the image should download and the result would be stored in applicationdata directory.
  • The progress can be monitored on the console.
  • Once the download is complete. the appropriate task will be removed from pending downloads and the downloaded file name will be added to the downloaded list.

2. Foreground download initiation + Background download
* User initiates a background download while in the foreground. Then the app is but into background, download completes while the app is in the background itself.

Instructions.

  • Create a app with the above provided app.js.
  • When the app starts click on the download button. and put the app into background by pressing on the home button on the device.
  • The image should download and the result would be stored in applicationdata directory.
  • The progress can be monitored on the console.
  • Once the download is complete. the appropriate task will be removed from pending downloads and the downloaded file name will be added to the downloaded list.

3. Background Fetch causing a background download
****NOTE :: This would be the most important and slightly tricky use case as you would have to use Xcode to complete this.

  • The app is launched due to a 'backgroundfetch' event which would trigger a background download.

INSTRUCTIONS ON TESTING

initial test setup

  • Create a app with the above provided app.js.
  • Include the following in your tiapp.xml
    <ios>
        <plist>
            <dict>
                <key>UIBackgroundModes</key>
                <array>
                    <string>fetch</string>
                </array>
            </dict>
        </plist>
        <min-ios-ver>7.0</min-ios-ver>
    </ios>
  • Buiild the app for iOS Simulator.
  • Once the app launches kill the simulator and Studio process.
  • Navigate to the apps build folder and native xcode app (should be /build/iphone/.xcodeproj)
  • Open the build project in xcode.
  • On the top right corner, Click on the schemes drop down (make sure you have selected any iOS 7 simulator before continue)
    schemes drop down
  • Click on Manage schemes from the drop down
    manage schemes
  • which would bring you to this screen.
    schemes window
  • Select one of the schemes (say: -universal)
    selecting the universal scheme
  • Click on the little gear at the left hand bottom corner of that the window to reveal another drop down menue.
    Duplicate scheme
  • Select duplicate option
  • On the new window that pops on top of the previous window Enter a new for the scheme and __select the launch due to a background fetch event option.
    screen shot 2013-11-12 at 11 11 46 pm
    actions
  • Hit OK
  • HIt OK
  • Now you should have a new scheme, which is automatically selected for you.

actual test

  • Click on the play/run button to build and launch the app into background.
  • Look at the console log to verify that a backgroundfetch event was fired.
  • Soon after the backgroundfetch event is fired backgroundtransfer event would fire indicating that the download relaunched the into background.
  • the rest of the of downloading events would fire short after.
  • Once the initial download is complete if you want to test again.
  • In the xcode menu bar select Debug Option.
  • Under Debug Option Select the Simulate Background Fetch option.
    debug-simulate background fetch
  • This would trigger another backgroundfetch.

Please do let me know if you get stuck on any of the steps.

@ghost ghost assigned vishalduggal Nov 8, 2013
@ghost ghost assigned matt-langston Nov 12, 2013
description: |
This property has no effect for apps that do not have the UIBackgroundModes key with
the fetch value in its Info.plist file. The default fetch interval for apps is
<replace>. Therefore, you must call this method and set a fetch interval before your
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace?

to the [endBackgroundHandler](Titanium.App.iOS.endBackgroundHandler) method.
type: String.
platforms: [iphone, ipad]
since: '3.2.0'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

osver: {ios: {min: "7.0"}}

@pec1985
Copy link
Contributor

pec1985 commented Nov 12, 2013

Note to self, testing with image url http://edmullen.net/test/rc.jpg since it's larger than the one provided in app.js

@pec1985
Copy link
Contributor

pec1985 commented Nov 12, 2013

FR PASSED

@pec1985
Copy link
Contributor

pec1985 commented Nov 12, 2013

@srahim I tested it and it works as described above.
One question I have is why is the module binary 61.8MB?

@srahim
Copy link
Contributor Author

srahim commented Nov 13, 2013

@vishalduggal addressed review comments.

@pec1985
Copy link
Contributor

pec1985 commented Nov 14, 2013

PR APPROVED!

pec1985 added a commit that referenced this pull request Nov 14, 2013
[TIMOB-14617] iOS 7 : Backgrounding Features
@pec1985 pec1985 merged commit 6c7e6fe into tidev:master Nov 14, 2013
@srahim srahim deleted the timob-14617-master branch December 10, 2013 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants