question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'split' of undefined

See original GitHub issue

Your Environment

Cordova CLI: 6.5.0 Ionic Framework Version: 3.2.1 Ionic CLI Version: 2.2.1 Ionic App Lib Version: 2.2.0 Ionic App Scripts Version: 1.3.7 ios-deploy version: Not installed ios-sim version: Not installed OS: Linux 3.13 Node Version: v6.6.0 Xcode version: Not installed

Context

Background service is not starting

Debug logs

HomePage.html:16 ERROR TypeError: Cannot read property 'split' of undefined
    at file:///android_asset/www/build/main.js:41923:75
    at Array.forEach (native)
    at file:///android_asset/www/build/main.js:41923:20
    at Map.forEach (native)
    at Headers.toJSON (file:///android_asset/www/build/main.js:41921:23)
    at JSON.stringify (<anonymous>)
    at androidExec (file:///android_asset/www/cordova.js:962:25)
    at Object.configure (file:///android_asset/www/plugins/cordova-plugin-mauron85-background-geolocation/www/backgroundGeolocation.js:39:9)
    at callCordovaPlugin (file:///android_asset/www/build/main.js:66865:43)
    at Observable._subscribe (file:///android_asset/www/build/main.js:66907:28)

##My plugin code

	startTracking(vehicleId) {
	 
	  // Background Tracking

		const config: BackgroundGeolocationConfig = {
						locationProvider:1,
			            desiredAccuracy: 10,
			            stationaryRadius: 10,
			            distanceFilter: 10,
			            interval:20000,
			            fastestInterval:20000,
			            activitiesInterval:10000,
			            debug: true, //  enable this hear sounds for background-geolocation life-cycle.
			            stopOnTerminate: false, // enable this to clear background location settings when the app terminates
					 	url: API_URL+'vehicles/'+vehicleId+'/location',
					    httpHeaders: this.auth.getHeaders(),
					    syncUrl:API_URL+'vehicles/'+vehicleId+'/location',																																																			
					    maxLocations: 200,	 
					    notificationTitle: 'CarPool Tracking',
					    notificationText: 'Enabled',
					    notificationIconColor: '#FEDD1E'		               
			    };

			this.backgroundGeolocation.configure(config)
			  .subscribe((location: BackgroundGeolocationResponse) => {

		    	this.backgroundGeolocation.finish(); // FOR IOS ONLY

		  	});

		  // Background Tracking

		  	this.backgroundGeolocation.start();	
	}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
gchokeencommented, Jun 20, 2017

It worked after commenting the httpHeaders

0reactions
mauron85commented, Nov 21, 2017

Notice: this issue has been closed because it has been reported for branch 2.x or later. It could be already fixed in v3 or is not relevant anymore. You may reopen this issue if it has been closed in error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot Read Property 'split' of Undefined - freeCodeCamp
Calling array[i].split(""); to split each string into substrings of characters is a valid approach, but it will throw TypeError: Cannot read ...
Read more >
How to prevent cannot read property split of ... - Meticulous
If different values are assigned to a variable several times, calling the split() method on the variable when it is set to undefined...
Read more >
Uncaught TypeError: Cannot read property 'split' of undefined
If og_date contains the date, it's probably a string, so og_date.value is undefined. Simply use og_date.split('-') instead of og_date.value.
Read more >
TypeError: Cannot read Property 'split' of Undefined in JS
The "Cannot read property 'split' of undefined" error occurs when trying to call the split() method on a variable that stores an undefined ......
Read more >
TypeError: Cannot read property 'split' of undefined - SitePoint
TypeError : Cannot read property 'split' of undefined ... Somebody please guide me. Zulfi. Zulf. ... If you want contractCode2 to be a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found