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

Native BackgroundMode add EventListener does not work #437

Closed
jgw96 opened this issue Aug 16, 2016 · 8 comments
Closed

Native BackgroundMode add EventListener does not work #437

jgw96 opened this issue Aug 16, 2016 · 8 comments
Assignees
Labels
Milestone

Comments

@jgw96
Copy link

jgw96 commented Aug 16, 2016

From @mburger81 on August 16, 2016 9:26

As described here in my post in the forum, I can not add an listener to activate

https://forum.ionicframework.com/t/error-on-backgroundmode-on/58979/4

using ionic2 beta.11

BackgroundMode.on('activate', function() {
});

EXCEPTION: TypeError: Cannot read property 'apply' of undefined
browser_adapter.js:84 EXCEPTION: TypeError: Cannot read property 'apply' of undefinedBrowserDomAdapter.logError @ browser_adapter.js:84BrowserDomAdapter.logGroup @ browser_adapter.js:94ExceptionHandler.call @ exception_handler.js:65(anonymous function) @ application_ref.js:337EventEmitter.subscribe.schedulerFn @ async.js:139SafeSubscriber.__tryOrUnsub @ Subscriber.js:225SafeSubscriber.next @ Subscriber.js:174Subscriber._next @ Subscriber.js:124Subscriber.next @ Subscriber.js:88Subject._finalNext @ Subject.js:128Subject._next @ Subject.js:120Subject.next @ Subject.js:77EventEmitter.emit @ async.js:127NgZone._zoneImpl.ng_zone_impl_1.NgZoneImpl.onError @ ng_zone.js:124NgZoneImpl.inner.inner.fork.onHandleError @ ng_zone_impl.js:74ZoneDelegate.handleError @ zone.js:327Zone.runTask @ zone.js:259ZoneTask.invoke @ zone.js:423
browser_adapter.js:84 STACKTRACE:BrowserDomAdapter.logError @ browser_adapter.js:84ExceptionHandler.call @ exception_handler.js:67(anonymous function) @ application_ref.js:337EventEmitter.subscribe.schedulerFn @ async.js:139SafeSubscriber.__tryOrUnsub @ Subscriber.js:225SafeSubscriber.next @ Subscriber.js:174Subscriber._next @ Subscriber.js:124Subscriber.next @ Subscriber.js:88Subject._finalNext @ Subject.js:128Subject._next @ Subject.js:120Subject.next @ Subject.js:77EventEmitter.emit @ async.js:127NgZone._zoneImpl.ng_zone_impl_1.NgZoneImpl.onError @ ng_zone.js:124NgZoneImpl.inner.inner.fork.onHandleError @ ng_zone_impl.js:74ZoneDelegate.handleError @ zone.js:327Zone.runTask @ zone.js:259ZoneTask.invoke @ zone.js:423
browser_adapter.js:84 TypeError: Cannot read property 'apply' of undefined
    at callCordovaPlugin (plugin.js:81)
    at Function.exports.wrap (plugin.js:221)
    at Function.value [as on] (plugin.js:284)
    at SafeSubscriber._next (app.ts:70)
    at SafeSubscriber.__tryOrUnsub (Subscriber.js:225)
    at SafeSubscriber.next (Subscriber.js:174)
    at Subscriber._next (Subscriber.js:124)
    at Subscriber.next (Subscriber.js:88)
    at XMLHttpRequest.XHRConnection.response.Observable_1.Observable.onLoad (xhr_backend.js:68)
    at ZoneDelegate.invokeTask (zone.js:356)BrowserDomAdapter.logError @ browser_adapter.js:84ExceptionHandler.call @ exception_handler.js:68(anonymous function) @ application_ref.js:337EventEmitter.subscribe.schedulerFn @ async.js:139SafeSubscriber.__tryOrUnsub @ Subscriber.js:225SafeSubscriber.next @ Subscriber.js:174Subscriber._next @ Subscriber.js:124Subscriber.next @ Subscriber.js:88Subject._finalNext @ Subject.js:128Subject._next @ Subject.js:120Subject.next @ Subject.js:77EventEmitter.emit @ async.js:127NgZone._zoneImpl.ng_zone_impl_1.NgZoneImpl.onError @ ng_zone.js:124NgZoneImpl.inner.inner.fork.onHandleError @ ng_zone_impl.js:74ZoneDelegate.handleError @ zone.js:327Zone.runTask @ zone.js:259ZoneTask.invoke @ zone.js:423
plugin.js:81 Uncaught TypeError: Cannot read property 'apply' of undefined

Copied from original issue: ionic-team/ionic-framework#7736

@keithdmoore
Copy link
Contributor

keithdmoore commented Aug 28, 2016

I am seeing a similar issue as well.

"EXCEPTION: Error: Uncaught (in promise): TypeError: Cannot read property 'apply' of undefined"

@andreasotto
Copy link

I've run into the same problem. Is just the documentation wrong (there is no second paramater in the documentation!) or is the implementation of that function erroneous? Anyway the current situation does not work.

@ihadeed
Copy link
Collaborator

ihadeed commented Sep 19, 2016

Sorry about that. The method on doesn't actually exist in the plugin's API. Not sure if it was a mistake when the wrapper was written or the developer has changed the API.

I will edit the wrapper soon to implement the correct methods.

@ihadeed ihadeed self-assigned this Sep 19, 2016
@ihadeed ihadeed added this to the 1.3.23 milestone Sep 19, 2016
@ihadeed ihadeed added the bug label Sep 19, 2016
@mlynch mlynch closed this as completed in f60d08b Sep 24, 2016
@mlynch
Copy link
Collaborator

mlynch commented Sep 24, 2016

Just added the new methods to this plugin along with a new @CordovaFunctionOverride decorator that handles situations where the plugin author expects developers to override a function in the plugin, like BackgroundMode.onactivate = function() {}. Instead, the plugin wraps that in an observable and handles it for you.

@whitty69
Copy link

stupid beginner question... how do I get the fix into my app?

@ramonornela
Copy link
Contributor

Problem that the version 2.0.3 is compatible with typescript 2.0 and ionic-angular 2.0.0-beta11 is not, only in beta.12 which will be launched soon.

@whitty69
Copy link

ok, thanks for that :-) I'll just need to be patient!

@tobiasfiechter
Copy link

tobiasfiechter commented Oct 13, 2016

@mlynch When will your fix be released?

Ok as a temporary fix for other devs: https://forum.ionicframework.com/t/how-to-use-cordova-plugin-backgroundmode-in-ionic-2-with-typescript/55278/3?u=cyberto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants