Skip to content

Commit

Permalink
#1 onHomeIconPressed when app was terminated - better solution
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Oct 15, 2015
1 parent 669b1d0 commit cf3bd14
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,6 @@ To disable the link preview feature again, do:
```

## 5. Changelog
* 1.1.0 Found a solid way to deal with timing when to call into `onHomeIconPressed`. Should always work now, even on coldstart.
* 1.0.1 Increased the timeouts a bit, so there is a better chance `onHomeIconPressed` gets called on coldstart. Thanks [#1](https://github.com/EddyVerbruggen/cordova-plugin-3dtouch/issues/1).
* 1.0.0 Initial release (untagged)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-3dtouch",
"version": "1.0.1",
"version": "1.1.0",
"description": "Add Quick Actions to your Home Screen which can be triggered by 3D Touch. Also, you can enable Link Preview with this plugin. Supported on iPhone6S an up.",
"cordova": {
"id": "cordova-plugin-3dtouch",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<plugin
id="cordova-plugin-3dtouch"
version="1.0.1"
version="1.1.0"
xmlns="http://apache.org/cordova/ns/plugins/1.0">

<name>3D Touch</name>
Expand Down
2 changes: 1 addition & 1 deletion src/ios/app/AppDelegate+threedeetouch.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ - (void) callJavascriptFunctionWhenAvailable:(NSString*)function {
if (threeDeeTouch.initDone) {
[threeDeeTouch.webView stringByEvaluatingJavaScriptFromString:function];
} else {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 100 * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 25 * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{
[self callJavascriptFunctionWhenAvailable:function];
});
}
Expand Down
2 changes: 2 additions & 0 deletions src/ios/app/ThreeDeeTouch.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

@property BOOL initDone;

- (void) deviceIsReady:(CDVInvokedUrlCommand*)command;

- (void) isAvailable:(CDVInvokedUrlCommand*)command;

- (void) configureQuickActions:(CDVInvokedUrlCommand*)command;
Expand Down
7 changes: 2 additions & 5 deletions src/ios/app/ThreeDeeTouch.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@

@implementation ThreeDeeTouch

- (void)pluginInitialize {
// make sure the app is awake
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 300 * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{
self.initDone = YES;
});
- (void) deviceIsReady:(CDVInvokedUrlCommand *)command {
self.initDone = YES;
}

- (void) isAvailable:(CDVInvokedUrlCommand *)command {
Expand Down
6 changes: 6 additions & 0 deletions www/ThreeDeeTouch.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ ThreeDeeTouch.prototype.configureQuickActions = function (icons, onSuccess, onEr
};

module.exports = new ThreeDeeTouch();

// call the plugin as soon as deviceready fires, this makes sure the webview is loaded,
// way more solid than relying on native's pluginInitialize.
document.addEventListener('deviceready', function() {
exec(null, null, "ThreeDeeTouch", "deviceIsReady", []);
}, false);

0 comments on commit cf3bd14

Please sign in to comment.