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-20522] Use FusedLocationProviderClient for Ti.Geolocation #9634

Merged
merged 8 commits into from Feb 21, 2018

Conversation

garymathews
Copy link
Contributor

@garymathews garymathews commented Nov 28, 2017

  • Use FusedLocationProviderClient when ti.playservices module is included in tiapp.xml, falling back to previous behavior if not available
TEST CASE
var win = Ti.UI.createWindow({ backgroundColor: 'gray' }),
    listView = Ti.UI.createListView(),
    count = 1;

Ti.Geolocation.accuracy = Ti.Geolocation.ACCURACY_HIGH;

function push (e) {
    var section = Ti.UI.createListSection({ headerTitle: '#' + count++ });
    if (e.success) {
        if (e.coords) {
            e = e.coords;
        }
        section.setItems([
            { properties: { title: 'LOCATION:\n' + e.latitude + ', ' + e.longitude, color: 'orange' } },
            { properties: { title: 'ALTITUDE:\n' + e.altitude, color: 'orange' } },
            { properties: { title: 'ACCURACY:\n' + e.accuracy, color: 'orange' } }
        ]);
    } else {
        section.setItems([
            { properties: { title: 'ERROR:\n' + e.error, color: 'red' } }
        ]);
    }
    listView.appendSection(section);
}

function getLocation() {
    Ti.Geolocation.addEventListener('location', push);
    Ti.Geolocation.getCurrentPosition(push);
}

win.addEventListener('open', function(){
    if(Ti.Geolocation.hasLocationPermissions()){
        getLocation();
    }else{
        Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS, function (e) {
            if (e.success) {
                getLocation();
            } else {
                alert('could not obtain location permissions');
            }
        });
    }
});

win.add(listView);
win.open();

NOTE: The play services libraries for the Geolocation module are only required to compile the SDK. They are not included with titanium builds and won't cause conflicts with ti.playservices. However, they will need updating if the Google API changes.

JIRA Ticket

@hansemannn
Copy link
Collaborator

@garymathews Does this also affect #9633?

@garymathews
Copy link
Contributor Author

@hansemannn #9633 is not affected by this

@@ -395,6 +428,8 @@ properties:
type: Number
permission: read-only
platforms: [android, iphone, ipad]
deprecated:
since: "2.0.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think they are deprecated for iOS. Maybe only deprecate and remove for Android?

@build
Copy link
Contributor

build commented Feb 21, 2018

Messages
📖

💾 Here's the generated SDK zipfile.

Generated by 🚫 dangerJS

@lokeshchdhry lokeshchdhry merged commit 9a2558d into tidev:master Feb 21, 2018
@lokeshchdhry
Copy link
Contributor

Oops forgot to comment before merging.

Checked the changes & geolocation works as expected in emulator without google playservices.

Studio Ver: 5.0.0.201712081732
SDK Ver: 7.2.0 local build
OS Ver: 10.13.2
Xcode Ver: Xcode 9.2
Appc NPM: 4.2.12
Appc CLI: 7.0.2
Daemon Ver: 1.0.1
Ti CLI Ver: 5.0.14
Alloy Ver: 1.11.0
Node Ver: 8.9.1
NPM Ver: 5.5.1
Java Ver: 1.8.0_101
Devices: ⇨ google Nexus 6P --- Android 8.0.0
⇨ google Nexus 5 --- Android 6.0.1

@sgtcoolguy sgtcoolguy modified the milestones: 7.2.0, 7.3.0 May 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants