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

onHomeIconPressed not working but configureQuickActions works fine #32

Open
enzor77 opened this issue Apr 3, 2017 · 19 comments
Open

onHomeIconPressed not working but configureQuickActions works fine #32

enzor77 opened this issue Apr 3, 2017 · 19 comments

Comments

@enzor77
Copy link

enzor77 commented Apr 3, 2017

Hi added the plugin to a project but I have some issues; QuickActions added properly but not fired when I use it.
I'm working with an iphone7 with iOS 10.3

Below is the code I used inside the app.run JS:

$ionicPlatform.ready(function ($cordovaGlobalization) {
   
   ThreeDeeTouch.configureQuickActions([
     {
       iconType: 'Search', // optional	  
       type: 'searchapplication', // optional, but can be used in the onHomeIconPressed callback
       title: 'Application', // mandatory
       subtitle: 'Search by Application' // optional
     },
     {
       iconType: 'Search', // optional, case insensitive	  
       type: 'searchcode',
       title: 'Code',
       subtitle: 'Search by Code' // optional
     },
     {
       iconType: 'Search', // iconType is case insensitive	  
       type: 'searchproduct',
       title: 'Product',
       subtitle: 'Search by Product' // optional		
     },
     {
       iconType: 'CapturePhoto', // iconType is case insensitive	  
       type: 'searchbarcode',
       title: 'Barcode',
       subtitle: 'Scan Barcode' // optional		
     }
   ]);

   ThreeDeeTouch.onHomeIconPressed = function(payload) {
     console.log("Icon pressed. Type: " + payload.type + ". Title: " + payload.title + ".");
     if 
     (payload.type == 'searchapplication') {$state.go('app.vehicles');} 
     else if 
     (payload.type == 'searchcode') {$state.go('app.code');} 
     else if 
     (payload.type == 'searchproduct') {$location.path('app/product');} 
     else if 
     (payload.type == 'searchbarcode') {$location.path('app/barcode');} 
     else {
       // wrapping in a timeout, otherwise it collides with the splashscreen
       setTimeout(function() {
         alert(JSON.stringify(payload));
       }, 500);
     }
   };
   	$rootScope.isWindows = device.platform == "windows";
   	
   	if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard && cordova.plugins.Keyboard.hideKeyboardAccessoryBar) {
           cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false);
       }
   	cordova.plugins.Keyboard.disableScroll( true );

   	setTimeout(function() {
   		navigator.splashscreen.hide();
   	}, 100);
   	        $rootScope.$apply(); // This resolved!
   });
@EddyVerbruggen
Copy link
Owner

Have you also tried it as shown in the readme?

@enzor77
Copy link
Author

enzor77 commented Apr 4, 2017

Any idea on how override the splashscreen collision?
Any help will be much appreciated

@enzor77
Copy link
Author

enzor77 commented Apr 4, 2017

Hi, what is teh difference between what I used and what is showed on readme?
I'm using same procedure, if not wrong...
Thanks a lot for your prompt reply

@enzor77
Copy link
Author

enzor77 commented Apr 4, 2017 via email

@santekotturi
Copy link
Contributor

santekotturi commented Apr 4, 2017

@enzor77 try wrapping onHomeIconPressed in addEventListener

document.addEventListener('deviceready', function () {
 ThreeDeeTouch.onHomeIconPressed = function(payload) {
     console.log("Icon pressed. Type: " + payload.type + ". Title: " + payload.title + ".");
     if 
     (payload.type == 'searchapplication') {$state.go('app.vehicles');} 
     else if 
     (payload.type == 'searchcode') {$state.go('app.code');} 
     else if 
     (payload.type == 'searchproduct') {$location.path('app/product');} 
     else if 
     (payload.type == 'searchbarcode') {$location.path('app/barcode');} 
     else {
       // wrapping in a timeout, otherwise it collides with the splashscreen
       setTimeout(function() {
         alert(JSON.stringify(payload));
       }, 500);
     }
   };
})

[edit]: also, are your injecting $state and $location ? can you try without those and just get it to console.log the payload?

@toriqo
Copy link

toriqo commented Apr 21, 2017

hi,

the plugin stopped working for me as well. I had some custom icon templates, working fine and all of a sudden it stopped working.
i've removed the plugin and re-added it, i've used the stock example code, nothing.
should i remove and re-add the ios platform? though i wouldn't want to do that and go through all the hassle with the pods etc.

might have something to do with ios 10.3 (iphone7)

also, if i add your example code in the .plist file, both of those actions open my front camera (opening the front camera is one of the options i have set in the configureQuickActions)

thanks

@toriqo
Copy link

toriqo commented May 1, 2017

@EddyVerbruggen is this repo still maintained?

@EddyVerbruggen
Copy link
Owner

@toriqo Sure, all PR's are welcome as always.

@toriqo
Copy link

toriqo commented May 4, 2017

@EddyVerbruggen well, i was expecting some feedback regarding this issue :)
do you know what's happening or should i do a pull request for a fix? :)

thanks

@EddyVerbruggen
Copy link
Owner

Do you have one?

@toriqo
Copy link

toriqo commented May 5, 2017

nope. but i could investigate and see what's wrong. just wanted to know if it's something you know about.

@JoxieMedina
Copy link

Anyone can help me , I'm experiencing the same problem with ionic v1 (1.3.1), the actions are correctly added but I can't make the method assigned to ThreeDeeTouch.onHomeIconPressed get trigger, I tried many ways to do it but no luck at the end I have an implementation pretty much like this : https://github.com/ashteya/ionic-tutorial-quickactions , If anyone can make it works please let me kwon how to do it

Greetings and thanks for your time and effort

@akaNightmare
Copy link

akaNightmare commented Mar 8, 2018

Guys, any movements to fix this issue?

@JoxieMedina
Copy link

Hi @akaNightmare , I managed to make this works with the following steps:

  1. Configure the Quick Actions in the config function in the angular module like this:
    ...
 .config(function () {
    document
      .addEventListener("deviceready", function () {
        ThreeDeeTouch.isAvailable(function (available) {
          if (available) { // Comment out this check if testing in simulator
            console.log('Configure 3D touch, available');
            // Configure Quick Actions
            ThreeDeeTouch.configureQuickActions([
              {
                type: 'send', // optional, but can be used in the onHomeIconPressed callback
                title: 'Enviar Dinero', // mandatory
                iconType: 'location' // optional
              }, {
                type: 'pay',
                title: 'Pay',
                iconType: 'compose' // optional
              }, {
                type: 'locations',
                title: 'Locations',
                iconType: 'markLocation' // optional
              }
            ]);

          }
        })

      }, false);

...

  1. Add the actions listener in the run function in the angular module like this:
    ...
.run(function ($rootScope) {
    document
      .addEventListener('deviceready', function () {
        ThreeDeeTouch.onHomeIconPressed = function (payload) {
          console.log("Icon pressed. Type: " + payload.type + ". Title: " + payload.title + ".");
          if (payload.type == 'send') {
            $rootScope.$broadcast('openQuickSend');
          } else if (payload.type == 'pay') {
            $rootScope.$broadcast('openQuickPay');
          } else if (payload.type == 'locations') {
            $rootScope.$broadcast('openQuickSendLocations');
          }
        };
      }, false)

...
3. Note that I'm using $rootScope.$broadcast() to emit another event in the rootScope so the actions can be trigger in the controllers for example I handle all the actions in the MainCtrl, each one look like this:

...

$rootScope.$on('openQuickSendLocations', function () {
      console.log('opening locations')
      $state.go('locations');
    });

...

I hope this helps you!

@akaNightmare
Copy link

@enzor77 thanks, however, I using ionic3.
Also, I found how to fix this issue, just need to update ionic/native package and particular commit for this fix -> danielsogl/awesome-cordova-plugins@6cd97ca

@jesobreira
Copy link

jesobreira commented Nov 7, 2019

Did we run into the same issue again?

The modification posted by @akaNightmare was done in a file that does not exist anymore on Ionic Native's codebase.

And onHomeIconPressed does not fire for me either, although configureQuickActions works. From my debugging, the plugin's performActionForShortcutItem is not running (using with Ionic/Capacitor).

@stevenleija
Copy link

Did we run into the same issue again?

The modification posted by @akaNightmare was done in a file that does not exist anymore on Ionic Native's codebase.

And onHomeIconPressed does not fire for me either, although configureQuickActions works. From my debugging, the plugin's performActionForShortcutItem is not running (using with Ionic/Capacitor).

I have the same issue. Were you able to get it to work?

@jesobreira
Copy link

Hi, @stevenleija ! I didn't. My codebase has changed recently to React Native, so I won't be looking at solutions anymore.

@mobileias
Copy link

hello

does anyone solve this issue into ionic 5 and capacitor?

My end also same issue,
it not called onHomeIconPressed

Thanks

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

9 participants