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

Android 6.0.1: Plugin not working #99

Open
ahsan154 opened this issue Oct 4, 2017 · 0 comments
Open

Android 6.0.1: Plugin not working #99

ahsan154 opened this issue Oct 4, 2017 · 0 comments

Comments

@ahsan154
Copy link

ahsan154 commented Oct 4, 2017

Hi Paul!

I went through your repositry and installed the plugin via cli as shown below
screenshot_2

every thing went well and then i pasted your code in my index.html in <script> tags but after initialization nothing happens below is my code:

 <script type="text/javascript">
            app.initialize();
            document.addEventListener("deviceready", onDeviceReady, false);
            function onDeviceReady() {
                //Make sure to get at least one GPS coordinate in the foreground before starting background services
                navigator.geolocation.getCurrentPosition(function () {
                    /// alert(59);
                    console.log("Succesfully retreived our GPS position, we can now start our background tracker.");
                }, function (error) {
                    console.error(error);
                });
            }
           
            //Get plugin
            var bgLocationServices = window.plugins.backgroundLocationServices;
            alert(70);
            //Congfigure Plugin
            bgLocationServices.configure({
                //Both
                desiredAccuracy: 20, // Desired Accuracy of the location updates (lower means more accurate but more battery consumption)
                distanceFilter: 0.01, // (Meters) How far you must move from the last point to trigger a location update
                debug: true, // <-- Enable to show visual indications when you receive a background location update
                interval: 1000, // (Milliseconds) Requested Interval in between location updates.
                useActivityDetection: true, // Uses Activitiy detection to shut off gps when you are still (Greatly enhances Battery Life)

                //Android Only
                notificationTitle: 'BG Plugin', // customize the title of the notification
                notificationText: 'Tracking', //customize the text of the notification
                fastestInterval: 1000 // <-- (Milliseconds) Fastest interval your app / server can handle updates

            });
            alert(86);
            //Register a callback for location updates, this is where location objects will be sent in the background
            bgLocationServices.registerForLocationUpdates(function (location) {
                console.log("We got an BG Update" + JSON.stringify(location));
            }, function (err) {
                console.log("Error: Didnt get an update", err);
            });
            alert(93);
            //Register for Activity Updates

            //Uses the Detected Activies / CoreMotion API to send back an array of activities and their confidence levels
            //See here for more information:
            //https://developers.google.com/android/reference/com/google/android/gms/location/DetectedActivity
            bgLocationServices.registerForActivityUpdates(function (activities) {
                console.log("We got an activity update" + activities);
            }, function (err) {
                console.log("Error: Something went wrong", err);
            });
            alert(104);

//            //On the first location success? Ie:
//                navigator.geolocation.getCurrentPosition(function() {
//                 //omitting initialization parameters...
//                 alert(113);
//                 bgLocationServices.start();
//                }, function(error) {
//                alert(116);
//                 console.error(error);
//                });
            alert(115);
            //Start the Background Tracker. When you enter the background tracking will start, and stop when you enter the foreground.
            bgLocationServices.start();

            alert(108);



            ///later, to stop
            // bgLocationServices.stop();
        </script>

So can you guide me where am i lacking? or it is not properly installed? although it is showing its inclusion in cordova_plugins.js too and folders are as well in appropriate places.

Regards,
Ahsan

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

No branches or pull requests

1 participant