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

Plugin 3DTouch bug #232

Closed
Bouzmine opened this issue Jun 17, 2016 · 5 comments
Closed

Plugin 3DTouch bug #232

Bouzmine opened this issue Jun 17, 2016 · 5 comments
Labels
Milestone

Comments

@Bouzmine
Copy link
Contributor

Hi,

I am having trouble with the 3DTouch plugin which was recently added. The configureQuickActions is OK, it's the onHomeIconPressed() that's bugging.

TypeError: undefined is not an object (evaluating 'util_1.get(window, pluginObj.pluginRef)[methodName].apply')

I think this could be related with #106.

@ihadeed
Copy link
Collaborator

ihadeed commented Jun 18, 2016

Hey @Bouzmine

Thanks for reporting this issue.

The problem is with the wrapper I created for that method. It's actually not a method, it's a property. (See https://github.com/EddyVerbruggen/cordova-plugin-3dtouch#onhomeiconpressed)

Since you are using the plugin, can you tell me which of the following is a better option:

  • Wrap the property, then use it as intended by the original developer, so your markup would look something like this:
import {ThreeDeeTouch} from 'ionic-native';

...

ThreeDeeTouch.onHomeIconPressed = (payload: any) => {
// do something with payload.type
// do something with payload.title
};
  • Write a custom wrapper so we can still provide an observable. The usage would be like this:
// import plugin
...
let subscription = ThreeDeeTouch.onHomeIconPressed().subscribe(
  (payload: any) => {
    // do stuff with data
  }
);
...
// then eventually stop processing that data
subscription.unsubscribe();

I'm not so sure if wrapping it with an observable would really work, but it should 😁

..

Let me know what you think is a better option, as I personally haven't used this plugin.

@ihadeed ihadeed added the bug label Jun 18, 2016
@ihadeed ihadeed added this to the 1.3.1 milestone Jun 18, 2016
@Bouzmine
Copy link
Contributor Author

I think option number 2 would better fit with Ionic Native's objective (providing observable wrapper for Cordova plugin, if I recall correctly). That said, if option 2 cannot work, option 1 would be just fine.

@mlynch
Copy link
Collaborator

mlynch commented Jun 21, 2016

I think this is what you mean by custom wrapper?

@ihadeed something like:

    /**
     * When a home icon is pressed, your app launches and this JS callback is invoked.
     * @returns {Observable<any>} returns an observable that notifies you when he user presses on the home screen icon
     */
    static onHomeIconPressed(): Observable<any> {
      return new Observable(observer => {
        window.ThreeDeeTouch && window.ThreeDeeTouch.onHomeIconPressed = observer.next.bind(observer);
      })
    }

@ihadeed
Copy link
Collaborator

ihadeed commented Jun 21, 2016

@mlynch Yes that's exactly what I meant.

@ihadeed
Copy link
Collaborator

ihadeed commented Jun 26, 2016

This should be fixed in next release. Let me know if you still have problems with it.

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

3 participants