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

ScreenOrientation.lockOrientation raises error #1001

Closed
ivanovvitaly opened this issue Jan 25, 2017 · 59 comments
Closed

ScreenOrientation.lockOrientation raises error #1001

ivanovvitaly opened this issue Jan 25, 2017 · 59 comments
Assignees

Comments

@ivanovvitaly
Copy link

ScreenOrientation.lockOrientation raises error, however orientation is changing.
This happens after updated for the issue

ionic-native: "2.4.1"

console.error: EXCEPTION: Uncaught (in promise): TypeError: undefined is not an object (evaluating
            'pluginResult.then') http://172.26.9.242:8100/build/main.js:418:21
            http://172.26.9.242:8100/build/main.js:371:19 t@http://172.26.9.242:8100/build/polyfills.js:3:11330
            tryNativePromise@http://172.26.9.242:8100/build/main.js:370:31
            ionViewWillUnload@http://172.26.9.242:8100/build/main.js:62499:96
            _lifecycle@http://172.26.9.242:8100/build/main.js:8632:37
            _willUnload@http://172.26.9.242:8100/build/main.js:8577:24
            _willUnload@http://172.26.9.242:8100/build/main.js:33508:25
            _cleanup@http://172.26.9.242:8100/build/main.js:33442:33
            _trnsFinish@http://172.26.9.242:8100/build/main.js:33367:26 [native code]
            onInvoke@http://172.26.9.242:8100/build/main.js:40827:43
            run@http://172.26.9.242:8100/build/polyfills.js:3:6487 http://172.26.9.242:8100/build/main.js:33311:28
            _didFinish@http://172.26.9.242:8100/build/main.js:11497:29
            _didFinishAll@http://172.26.9.242:8100/build/main.js:11484:28
            onTransitionEnd@http://172.26.9.242:8100/build/main.js:10931:31
            onTransitionEnd@http://172.26.9.242:8100/build/main.js:6512:25
[18:08:43]  console.error: ORIGINAL STACKTRACE:
[18:08:43]  console.error: s@http://172.26.9.242:8100/build/polyfills.js:3:4220
            t@http://172.26.9.242:8100/build/polyfills.js:3:11356
            tryNativePromise@http://172.26.9.242:8100/build/main.js:370:31
            ionViewWillUnload@http://172.26.9.242:8100/build/main.js:62499:96
            _lifecycle@http://172.26.9.242:8100/build/main.js:8632:37
            _willUnload@http://172.26.9.242:8100/build/main.js:8577:24
            _willUnload@http://172.26.9.242:8100/build/main.js:33508:25
            _cleanup@http://172.26.9.242:8100/build/main.js:33442:33
            _trnsFinish@http://172.26.9.242:8100/build/main.js:33367:26 [native code]
            onInvoke@http://172.26.9.242:8100/build/main.js:40827:43
            run@http://172.26.9.242:8100/build/polyfills.js:3:6487 http://172.26.9.242:8100/build/main.js:33311:28
            _didFinish@http://172.26.9.242:8100/build/main.js:11497:29
            _didFinishAll@http://172.26.9.242:8100/build/main.js:11484:28
            onTransitionEnd@http://172.26.9.242:8100/build/main.js:10931:31
            onTransitionEnd@http://172.26.9.242:8100/build/main.js:6512:25
@ihadeed ihadeed self-assigned this Jan 26, 2017
@TomDemulierChevret
Copy link

Same issue here, the method call works but it raises an error too :

main.js:100585 EXCEPTION: Uncaught (in promise): TypeError: Cannot read property 'then' of undefined
TypeError: Cannot read property 'then' of undefined
    at file:///android_asset/www/build/main.js:564:21
    at file:///android_asset/www/build/main.js:517:17
    at new t (file:///android_asset/www/build/polyfills.js:3:11329)
    at tryNativePromise (file:///android_asset/www/build/main.js:516:20)
    at getPromise (file:///android_asset/www/build/main.js:538:16)
    at wrapOtherPromise (file:///android_asset/www/build/main.js:559:12)
    at Function.<anonymous> (file:///android_asset/www/build/main.js:708:20)
    at Function.value [as lockOrientation] (file:///android_asset/www/build/main.js:772:53)
    at ScreenOrientationService.init (file:///android_asset/www/build/main.js:85542:85)
    at file:///android_asset/www/build/main.js:163401:38
ErrorHandler.handleError @ main.js:100585
next @ main.js:79754
schedulerFn @ main.js:81264
SafeSubscriber.__tryOrUnsub @ main.js:5600
SafeSubscriber.next @ main.js:5549
Subscriber._next @ main.js:5502
Subscriber.next @ main.js:5466
Subject.next @ main.js:10408
EventEmitter.emit @ main.js:81256
NgZone.triggerError @ main.js:82106
onHandleError @ main.js:82085
t.handleError @ polyfills.js:3
e.runGuarded @ polyfills.js:3
r @ polyfills.js:3
i @ polyfills.js:3
main.js:100590 ORIGINAL STACKTRACE:
ErrorHandler.handleError @ main.js:100590
next @ main.js:79754
schedulerFn @ main.js:81264
SafeSubscriber.__tryOrUnsub @ main.js:5600
SafeSubscriber.next @ main.js:5549
Subscriber._next @ main.js:5502
Subscriber.next @ main.js:5466
Subject.next @ main.js:10408
EventEmitter.emit @ main.js:81256
NgZone.triggerError @ main.js:82106
onHandleError @ main.js:82085
t.handleError @ polyfills.js:3
e.runGuarded @ polyfills.js:3
r @ polyfills.js:3
i @ polyfills.js:3
main.js:100591 Error: Uncaught (in promise): TypeError: Cannot read property 'then' of undefined
TypeError: Cannot read property 'then' of undefined
    at main.js:564
    at main.js:517
    at new t (polyfills.js:3)
    at tryNativePromise (main.js:516)
    at getPromise (main.js:538)
    at wrapOtherPromise (main.js:559)
    at Function.<anonymous> (main.js:708)
    at Function.value [as lockOrientation] (main.js:772)
    at ScreenOrientationService.init (main.js:85542)
    at main.js:163401
    at s (polyfills.js:3)
    at s (polyfills.js:3)
    at polyfills.js:3
    at t.invokeTask (polyfills.js:3)
    at Object.onInvokeTask (main.js:82055)
    at t.invokeTask (polyfills.js:3)
    at e.runTask (polyfills.js:3)
    at i (polyfills.js:3)
ErrorHandler.handleError @ main.js:100591
next @ main.js:79754
schedulerFn @ main.js:81264
SafeSubscriber.__tryOrUnsub @ main.js:5600
SafeSubscriber.next @ main.js:5549
Subscriber._next @ main.js:5502
Subscriber.next @ main.js:5466
Subject.next @ main.js:10408
EventEmitter.emit @ main.js:81256
NgZone.triggerError @ main.js:82106
onHandleError @ main.js:82085
t.handleError @ polyfills.js:3
e.runGuarded @ polyfills.js:3
r @ polyfills.js:3
i @ polyfills.js:3
polyfills.js:3 Unhandled Promise rejection: Cannot read property 'then' of undefined ; Zone: angular ; Task: Promise.then ; Value: TypeError: Cannot read property 'then' of undefined
    at main.js:564
    at main.js:517
    at new t (polyfills.js:3)
    at tryNativePromise (main.js:516)
    at getPromise (main.js:538)
    at wrapOtherPromise (main.js:559)
    at Function.<anonymous> (main.js:708)
    at Function.value [as lockOrientation] (main.js:772)
    at ScreenOrientationService.init (main.js:85542)
    at main.js:163401 TypeError: Cannot read property 'then' of undefined
    at file:///android_asset/www/build/main.js:564:21
    at file:///android_asset/www/build/main.js:517:17
    at new t (file:///android_asset/www/build/polyfills.js:3:11329)
    at tryNativePromise (file:///android_asset/www/build/main.js:516:20)
    at getPromise (file:///android_asset/www/build/main.js:538:16)
    at wrapOtherPromise (file:///android_asset/www/build/main.js:559:12)
    at Function.<anonymous> (file:///android_asset/www/build/main.js:708:20)
    at Function.value [as lockOrientation] (file:///android_asset/www/build/main.js:772:53)
    at ScreenOrientationService.init (file:///android_asset/www/build/main.js:85542:85)
    at file:///android_asset/www/build/main.js:163401:38
o @ polyfills.js:3
r @ polyfills.js:3
i @ polyfills.js:3
polyfills.js:3 Error: Uncaught (in promise): TypeError: Cannot read property 'then' of undefined
TypeError: Cannot read property 'then' of undefined
    at main.js:564
    at main.js:517
    at new t (polyfills.js:3)
    at tryNativePromise (main.js:516)
    at getPromise (main.js:538)
    at wrapOtherPromise (main.js:559)
    at Function.<anonymous> (main.js:708)
    at Function.value [as lockOrientation] (main.js:772)
    at ScreenOrientationService.init (main.js:85542)
    at main.js:163401
    at main.js:564
    at main.js:517
    at new t (polyfills.js:3)
    at tryNativePromise (main.js:516)
    at getPromise (main.js:538)
    at wrapOtherPromise (main.js:559)
    at Function.<anonymous> (main.js:708)
    at Function.value [as lockOrientation] (main.js:772)
    at ScreenOrientationService.init (main.js:85542)
    at main.js:163401
    at s (polyfills.js:3)
    at s (polyfills.js:3)
    at polyfills.js:3
    at t.invokeTask (polyfills.js:3)
    at Object.onInvokeTask (main.js:82055)
    at t.invokeTask (polyfills.js:3)
    at e.runTask (polyfills.js:3)
    at i (polyfills.js:3)

The method ScreenOrientation.lockOrientation is called this way and worked perfectly fine until ionic-native update 2.4.1.

        if (this.platform.is('cordova')) {
            ScreenOrientation.lockOrientation(this.getOrientation());
        }

@RafaelKr
Copy link

RafaelKr commented Jan 26, 2017

Same for me. TypeError: Cannot read property 'then' of undefined
But it should return a promise: https://github.com/apache/cordova-plugin-screen-orientation/blob/master/www/screenorientation.js#L71

BTW: One Thousand and One issues!

Edit: This fixes the problem

ionic plugin rm cordova-plugin-screen-orientation --save
ionic plugin add https://github.com/apache/cordova-plugin-screen-orientation --save

Who knows how to update the link which ionic plugin add is using? Is it fetched from npm? Do we have to contact the author of the old repository or how does this work?

@ivanovvitaly
Copy link
Author

@RafaelKr I tried rm/add plugin and after first app execution error was not occurred. All subsequent app executions failed with the original error. Even if you try to rm/add plugin before each app execution further it fails constantly. So, looks like a glitch.

@RafaelKr
Copy link

@ivanovvitaly Try to do a platform rm and then platform add again. Sometimes it works like magic.

@ihadeed
Copy link
Collaborator

ihadeed commented Jan 26, 2017

Try adding @latest when installing. Example:

ionic plugin add cordova-plugin-screen-orientation@latest

@TomDemulierChevret
Copy link

TomDemulierChevret commented Jan 27, 2017

@ihadeed We can't use

ionic/cordova plugin add cordova-plugin-screen-orientation@latest

Because it will use the npm registry which point to this git repo : https://github.com/gbenvenuti/cordova-plugin-screen-orientation
But this repo is not maintened anymore, instead we must use the official appache one : https://github.com/apache/cordova-plugin-screen-orientation

The version 1.4.2 (present in npm, in the old git repo and as the latest release of the appache repo) causes the issue.
Only the latest version (2.0.0 as stated in the changelod but not tagged yet) fixes the issue (for me at least).

So, just remove the plugin and install it again with :

cordova plugin add https://github.com/apache/cordova-plugin-screen-orientation --save

@ivanovvitaly
Copy link
Author

ivanovvitaly commented Jan 27, 2017

@ihadeed Latest doesn't help. Code below raises error

ScreenOrientation.lockOrientation('portrait').then(() => {
    console.log('locked');
});

@ivanovvitaly
Copy link
Author

@RafaelKr I missed you are using apache url.
I installed plugin from repo https://github.com/apache/cordova-plugin-screen-orientation and screen orientation stoped working completely.

If i use code below it runs without errors and prints to console, but screen is not being rotated!

ScreenOrientation.lockOrientation('portrait').then(() => {
    console.log('locked');
});

@TomDemulierChevret
Copy link

TomDemulierChevret commented Jan 27, 2017

@ivanovvitaly On which platform are you testing it ?
On Android 7.1.1 (Nexus 5x), it does lock and rotate the screen with the last version from Apache repo.

Need to test on iOS thought.

@RafaelKr
Copy link

@ivanovvitaly Maybe you can try this:

ionic plugin rm cordova-plugin-screen-orientation --save
ionic plugin add https://github.com/apache/cordova-plugin-screen-orientation --save
ionic platform rm android --save
ionic platform add android --save

@TomDemulierChevret
Copy link

Or, if you want to clean everything (you may have other platforms than Android) :

delete /platforms directory
delete /plugins directory

Then run :

cordova plugin rm cordova-plugin-screen-orientation --save
cordova plugin add https://github.com/apache/cordova-plugin-screen-orientation --save
cordova prepare

@ivanovvitaly
Copy link
Author

I set up new project from scratch and installed screen orientation plugin from apache repo.

Android: confirm code executes without errors and screen orientation changes.
iOS: code executes without errors, however screens orientation doesn't change. Tested on iOS 10.2

@ihadeed
Copy link
Collaborator

ihadeed commented Jan 27, 2017

@TomDemulierChevret thanks for pointing that out.

I will probably revert the change and make our wrapper work with the npm package since that's what everybody has installed. Then I will publish this as a breaking change in ionic-native@3.0.0.

@RafaelKr
Copy link

@ivanovvitaly: Is the old plugin working on iOS 10.2?

@ihadeed: If the old plugin also doesn't work on iOS 10.2, then I think the best solution would be, if the apache package is installed, if you install cordova-plugin-screen-orientation. What would be the steps to change this? Do we have to contact the old maintainer to change the github URL in his npm repo? If that would be done, then you could keep the change.

@ivanovvitaly
Copy link
Author

@RafaelKr Yes, the old pluging that is installed by default is working on both platforms, inspite of it raises error

@ihadeed
Copy link
Collaborator

ihadeed commented Jan 28, 2017

@RafaelKr the old developer needs to give apache the permission to publish the plugin on npm.

@tassiocaique
Copy link

I've got the same error. I followed the steps above but they didn't solve my problem.

@ivanovvitaly
Copy link
Author

ivanovvitaly commented Jan 30, 2017

I set ionic-native to 2.4.0 in package.json file while Guys resolving the issue. ScreenOrientation.lockOrientation() doesn't return promise in 2.4.0, but works fine on both platforms and without errors.

@tabirkeland
Copy link

Any update on this? Still seeing the issue with "ionic-native": "2.5.1"

@mehrad-rafigh
Copy link

@TomDemulierChevret guide helped me. I am using ionic-native 2.5.1 and cordova plugin add https://github.com/apache/cordova-plugin-screen-orientation --save is the correct way to add the plugin.

@supryin
Copy link

supryin commented Feb 24, 2017

Facing the same bug. Tried the solution with Apache. Any ideas? Thank you!

JiaLiPassion added a commit to JiaLiPassion/ionic-native that referenced this issue Feb 26, 2017
@supryin
Copy link

supryin commented Feb 26, 2017

@JiaLiPassion thank you! How can I test your fix, before it was merged with a master branch?

@JiaLiPassion
Copy link
Contributor

@supryin , I just tested it in my environment, you can try with the attached dist file which I built with the fix.
dist.zip

JiaLiPassion added a commit to JiaLiPassion/ionic-native that referenced this issue Feb 27, 2017
@supryin
Copy link

supryin commented Feb 27, 2017

@JiaLiPassion thank you! I tried. Copied the files into ...node_modules\ionic-native. Still getting the same error. But this time if I write ScreenOrientation.lockOrientation("landscape"); without setTimeout the video even doesn't start playing. With old version of the plugin the video started to play with that code.

@JiaLiPassion
Copy link
Contributor

JiaLiPassion commented Feb 27, 2017

@supryin, I also tried in my application, the error is gone, so could debug with chrome://inspect to see the {sync:true} is passed into Cordova correctly? could you post your sample application?

@supryin
Copy link

supryin commented Feb 27, 2017

@JiaLiPassion how can I check if the dist folder is built into the app?

@JiaLiPassion
Copy link
Contributor

@supryin , you can just open your vendor.bundle.js(or main.bundle.js), to look for the string below

 __decorate([
        __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__plugin__["g" /* Cordova */])({ sync: true })
    ], ScreenOrientation, "lockOrientation", null);

in the original version, the property will be {otherPromise: true}

@JiaLiPassion
Copy link
Contributor

@supryin, could you post the error stack trace?

@supryin
Copy link

supryin commented Feb 27, 2017

@JiaLiPassion here it is:
TypeError: Cannot read property 'apply' of undefined
at callCordovaPlugin (http://localhost:8100/build/main.js:77717:38)
at Function. (http://localhost:8100/build/main.js:77907:20)
at Function.value [as lockOrientation] (http://localhost:8100/build/main.js:77980:53)
at OnboardingStartComponent.playVideo (http://localhost:8100/build/main.js:115848:31)
at CompiledTemplate.proxyViewClass.View_OnboardingStartComponent0.handleEvent_6 (/AppModule/OnboardingStartComponent/component.ngfactory.js:247:34)
at CompiledTemplate.proxyViewClass. (http://localhost:8100/build/main.js:11126:37)
at HTMLVideoElement. (http://localhost:8100/build/main.js:34252:36)
at t.invokeTask (http://localhost:8100/build/polyfills.js:3:9723)
at Object.onInvokeTask (http://localhost:8100/build/main.js:7478:37)
at t.invokeTask (http://localhost:8100/build/polyfills.js:3:9659)

@JiaLiPassion
Copy link
Contributor

It is because pluginInstance doesn't have the methodName, could you debug

at callCordovaPlugin (http://localhost:8100/build/main.js:77717:38)

in your code, to see, pluginInstance's properties, and methodName, I think you may use the wrong version of screen oritentation.

@supryin
Copy link

supryin commented Feb 27, 2017

@JiaLiPassion here it is:
image

@JiaLiPassion
Copy link
Contributor

@supryin, please open pluginInstance and pluginObj to see all their methods. And what's your version of screen orientaion?

@supryin
Copy link

supryin commented Feb 27, 2017

@JiaLiPassion I installed from my package.json:
"cordovaPlugins": [
"cordova-plugin-device",
"cordova-plugin-console",
"cordova-plugin-whitelist",
"cordova-plugin-splashscreen",
"cordova-plugin-statusbar",
"cordova-plugin-inappbrowser",
"cordova-plugin-pin-dialog",
"cordova-plugin-google-analytics",
"ionic-plugin-keyboard",
"cordova-plugin-screen-orientation"
],
and I use ionic-native 2.5.1
Methods are coming...

@supryin
Copy link

supryin commented Feb 27, 2017

@JiaLiPassion here:
image

@supryin
Copy link

supryin commented Feb 27, 2017

image

@supryin
Copy link

supryin commented Feb 27, 2017

@JiaLiPassion looks like your last comment got deleted

@JiaLiPassion
Copy link
Contributor

@supryin , yes,

  1. please close pluginInstance.prototype, I need to see all properties of pluginInstance itself.
  2. and please add a watch to see pluginInstance['lockOrientation'] is undefined or not

@supryin
Copy link

supryin commented Feb 27, 2017

@JiaLiPassion here:
image

@JiaLiPassion
Copy link
Contributor

@supryin, it seems the pluginReference is not correct, pluginObject is ok, could you post your repository?

@supryin
Copy link

supryin commented Feb 27, 2017

@JiaLiPassion what do you mean by post the repository?

@JiaLiPassion
Copy link
Contributor

@supryin , means upload your whole project to a github repository , so I can download and debug it.
you test it on android/iOS? OS version?

@supryin
Copy link

supryin commented Feb 27, 2017

@JiaLiPassion I am sorry ,I cant do this. It is a corporate project.
I am testing in Chrome / Windows and did tests on Android 6.
However. I just made a new release build for Android and ... it works. It still doesn't work on Windows / Chrome.

@JiaLiPassion
Copy link
Contributor

JiaLiPassion commented Feb 27, 2017

@supryin , sure, what is your test environment, (android/ios) and version? you can simply test with a very simple page to see the object return from

 window['Screen'] 

it seems it return a non complete instance.

And you can also debug

addScreenOrientationApi method in cordova-plugin-screen-orientation/www/screenorientation.js
to see the screenObject before and after the function.

if you can post a sample repository(not your project of your company but a very simple project only include Screen Orietation plugin) to demo the issue, I can help you with it.

@supryin
Copy link

supryin commented Feb 28, 2017

@JiaLiPassion thank you! I'll try. I will also test it on iOS. For now it doesn't work on Windows 10/ Chrome, but works on Android 5

@JiaLiPassion
Copy link
Contributor

@supryin, the plugin may support windows 10 Store application, but I think it may not support chrome on windows 10. Android/iOS should work as expected.

@ihadeed ihadeed closed this as completed in 104532e Mar 2, 2017
@saridakis
Copy link

@supryin, did you solve your problem with the error, "TypeError: Cannot read property 'apply' of undefined"? I have the same issue here .....

@supryin
Copy link

supryin commented Mar 6, 2017

@saridakis yes, on Android and iOS. Use the dist.zip provided by @JiaLiPassion . On Windows / Chrome the error still there. Meanwhile, I think, the master branch was updated with the fix, so you should be able to just add the working version over npm.

@saridakis
Copy link

@supryin one more question... which repository did you use? this one 'cordova plugin add https://github.com/apache/cordova-plugin-screen-orientation --save' or this 'cordova plugin add cordova-plugin-screen-orientation --save'? With the latest the error has been fixed, but on IOS, the command lockOrientation does nothing .... with the first one, on IOS, I get a message that no plugin is installed .... IOS version is 10.11

ihadeed added a commit that referenced this issue Mar 7, 2017
* 2.5.0

* chore(): update changelog

* fix(pin-dialog): add missing errorIndex

* 2.5.1

* chore(): update changelog

* fix(zip): progress callback is optional (#1049)

* fix(apprate): add missing Windows Store option (#1072)

* Update file-chooser.ts (#1071)

Removed semicolon after .then() in usage instructions

* docs(device-motion): update interface names (#1076)

AccelerationData interface is wrongly named in docs. It should be DeviceMotionAccelerationData. And I added it to import statement.

* feat(inappbrowser): add interface for IAB options (#1065)

* Add InAppBrowserOptions Interface for better tooling.

* feat(inappbrowser): add  interface for IAB options

* Add more constructor tests.

* Add missing iOS options.

* docs(media): update method usage (#1089)

* fix(push): add the missing option clearBadge (#1087)

* docs(badge): fix example (#1096)

Error in code example (supplied parameters do not match call signature)

* fix(imagepicker): add outputType option (#1098)

* fix(facebook): fixes issue when not supplying default params (#1088)

* Fix default facebook logEvent parameters

* Implement correct parameters format in facebook logEvent method

* Update ibeacon.ts (#1099)

Return type of `getAuthorizationStatus()` made more explicit.

* fix(file): add missing exports (#1101)

Any declaration that is not being exported is missing from the resulting d.ts declaration files.

* Add InAppBrowserOptions interface to documentation. (#1103)

* Update sqlite.ts (#1106)

Added a bracket to remove the syntax error

* update device orientation docs to reflect renaming of CompassHeading interface (#1107)

* Move marker code inside MAP_READY (#1108)

The code to set the camera position and marker should be moved inside the function handling MAP_READY.  Otherwise they execute before the event is fired and it doesn't work.

* refactor(file): accept ArrayBuffer for data to write (#1109)

* docs(google-maps): fix param type

closes #1110

* fix(media): add missing pauseRecord and resumeRecord methods (#1122)

* docs(stripe): fix type and naming issues (#1129)

* refactor(paypal): fix type of items (#1125)

Type of items should be Array<PayPalItem> instead of string.

* fix(serial): Serial.requestPermission() options are optional (#1128)

* add success/error indices

* feat(browser-tab): add browser tab plugin (#1126)

* feature: added hasPermission function to Firebase fixes #1115

* feat: Implemented support for BrowserTab #1077

* docs(browser-tab): add proper docs

* fix(background-geolocation): configure returns a promise

closes #1118

* docs(background-geolocation): add return types and platforms

* fix(contacts): allow passing asterisk as contact field type

closes 1093

* fix(contacts): allow passing asterisk as contact field type

closes #1093

* fix(plugin): revert changes to support stable version (#1116)

 fix #1001

* feat(file): add system paths

* feat(app-update): add cordova-plugin-app-update support (#1105)

* add new app-update plugin

* update plugin info

* docs(app-update): add docs

* feat(alipay): add alipay support. (#1097)

* add cordova-alipay-base plugin. to support Alipay payment

* change ALI_PID to APP_ID, make it same with the latest SDK

* rewrite comments

* docs(google-maps): improve docs (#1095)

Move `map.moveCamera(position);` inside the MAP_READY event.
Allow to zoom the map on first launch (both iOS and Android).

* fix(file): remove FileError from return type (#1086)

Promises that reject with a `FileError` are not of the type `Promise<T|FileError>`, but `Promise<T>`.

The previous declarations of `Promise<T|FileError>` would break typing further down the chain where you are trying to use the value that the typing says could be `T|FileError` but in reality could only be `T`.

* feat(google-maps): add constant for map type

* fix(file): platform Browser will raise a an DOMException (#1082)

fix(File): Platform Browser will raise a an DOMException on resoleLocalFilesystemUrl and tries to write on readonly property DOMException err.message in fillErrorMessage

* feat(local-notifications): support for icon background color (#1079)

The Cordova plugin Ionic Natives uses allows specifying the background color of the smallIcon.  By not including it in your interface you force users to use the default color for their version of Android.  While the LocalNotification plugin is not well documented, it does include this feature, see Options.java line 253:

```
/**
     * @return
     *      The notification background color for the small icon
     *      Returns null, if no color is given.
     */
    public int getColor() {
        String hex = options.optString("color", null);

        if (hex == null) {
            return NotificationCompat.COLOR_DEFAULT;
        }

        int aRGB = Integer.parseInt(hex, 16);

        return aRGB + 0xFF000000;
    }
```

I've simply added the option to the interface as well as a short description.

This lets you go from the default color (varies by Android version): https://goo.gl/photos/nERcj4GZgapy8aee9
To any color you'd like: https://goo.gl/photos/t8V9WVba8jDU49aHA
And also works if you also specify a large icon: https://goo.gl/photos/gWQYwa12djmdXfYcA

* feat(unique-device-add): add UniqueDeviceId plugin (#1064)

* fix plugin

* feat(text-to-speech): Add stop method (#1063)

vilicvane/cordova-plugin-tts#32

* feat(appodeal): adds Appodeal SDK wrappers for iOS and Android (#1031)

* feat(Appodeal) bootrapping

* starting docs

* more docs

* feat(appodeal): add event Observables

* feat(appodeal): replace Cordova Observable events with #.fromEvent()

* feat(appodeal): update decorator metadata

* feat(couchbase-lite): add CouchbaseLite cordova plugin (#1025)

* feat(CouchbaseLite): add CouchbaseLite cordova plugin

* add plugin url

* feat(background-fetch): Adding Background Fetch requested in #990 (#1013)

* Adding Background Fetch (https://github.com/transistorsoft/cordova-plugin-background-fetch) requested in #990

* Adding BackgroundFetch to index

* feat(gyroscope): add Gyroscope plugin (#1004)

* add gyroscope.ts to plugins

* add gyroscope to index

* Update gyroscope.ts

* Update gyroscope.ts

* Revert "fix(File): typing where `FileError` can be thrown" (#1130)

* tslint and fix build issues

* 2.6.0

* chore(): update changelog

* fix(core): dont check if method exists when overriding

fixes #1043

* fix(file): fix writeExistingFile

closes #1044

* feat(diagnostic): add new methods

closes #1045

* feat(background-mode): replace event listeners with on method

The methods onactivate, ondeactive and onfailure no longer exist. You must now use `on` method.

* feat(background-mode): add missing functions

 closes #1078

* tslint

* set GoogleMapsMapTypeId to private

* remove beta from stripe

* 2.7.0

* chore(): update changelog

* feat(app-preferences): added cordova-plugin-app-preferences support (#1084)

* (feat) added cordova-plugin-app-preferences support

* replaced callback functions with promises

* updated example

* (feat) added cordova-plugin-browsertab support

* Revert "(feat) added cordova-plugin-browsertab support"

This reverts commit 00eb5cf.

* (update) synchronize fetch

* feat(photo-library): added cordova-plugin-photo-library (#1102)

* feat(photo-library): added cordova-plugin-photo-library

* CordovaFiniteObservable moved to photo-library.
Overloads are marked as private.

* refactor(photo-library): fixed circleci failing in 2.7.0 (#1132)

* feat(photo-library): added cordova-plugin-photo-library

* CordovaFiniteObservable moved to photo-library.
Overloads are marked as private.

* fixed typescript error in 2.7.0

* feat(health): add wrapper for cordova-plugin-health (#1039)

* feat(health): add wrapper for cordova-plugin-health

* fix(Health): add optional params to QueryOptions for .query()

* docs(health): fix javadoc of interfaces

* fix(health): remove unused Plugin option

* docs(health): add missing documentation

* doc(health): add promise to return

* doc(health): remove empty lines

* doc(health): Add description & reference to repo

* doc(health: add "return {Promise<any>}"

* refactor(safari-view-controller): hide returns promise

* fix typo in ibeacon plugin (#1138)

* fix(file): fix return types

fixes #1139

* docs(background-geolocation): fix param docs

* refactor(health): fix return types and prefix interfaces

* 2.8.0

* chore(): update changelog

* docs(sqlite): syntax error resolved (#1142)

* Syntax error resolved

The `{}` should be `[]`, but since there is no binding we do not get error. In case we add one, then the syntax will be incorrect.

* Fixed a syntax error
@supryin
Copy link

supryin commented Mar 7, 2017

@saridakis I reference it in my package.json and install it with the latest ionic native.

@adilhaddaoui
Copy link

if anyone still looking for solving this issue ...
the solution is just update your ionic-native to latest version which is 2.8.0 now.

how to ? : first check your ionic-native version by typing "npm list ionic-native" if its not 2.8.0 then this is your issue solve it by running "npm update ionic-native" and check if it's updated, if not then just go to your package.json and change version of ionic-native to 2.8.0 then go back and run npm install !

this will solve the issue ... and it worked for me like sharp.

ihadeed added a commit that referenced this issue Mar 20, 2017
* feat(push): plugin is now instance based

no more callbacks

closes #250

* fix(push): fix typo in PushEvents enum

* fix constructor

* feat(push): add subscribe/unsubscribe

fixes #861

* First try

* Moving to modules

* Removed

* Moving things aroudn

* tsconfig for plugins

* Plugin tsconfigs

* Core kind of buidls

* Core

* Plugin tsconfig

* Test

* Remove core

* Build

* Individual packages

* Build and push

* Some stuff

* Bump

* Update core-package.json.template

* Update plugin-package.json.template

* 3.0.0

* Working on injectable

* Updates

* Checkpoint

* More stuff

* Remove duplicate injectables

* Remove lots of static stuff with a fancy regex

* Fix build errors

* chore(): nodejs build script

* chore(): move fs-extra-promise to devDeps

* feat(): make instance based plugins injectable

* Cleanup

* chore(build): convert dependencies to peer dependencies

* chore(build): add auto install scripts (#1059)

* feat(core): auto install scripts

* minor fixes

* minor fixes

* remove prompt message

* fix(plugins): rename packages/classes

* rename google maps

* gulp task to generate readme files

* readme templates

* automating readme file generation and adding it to CI

# Conflicts:
#	src/@ionic-native/plugins/googlemap/index.ts
#	src/@ionic-native/plugins/inappbrowser/index.ts
#	src/@ionic-native/plugins/media/index.ts
#	src/@ionic-native/plugins/sqlite/index.ts

* outputting readmes to dist dir instead of src

* updating package name in usage instructions

* chore(): ngc build

* fix build

* 3.0.1-0

* 3.1.0-alpha.1

* fix AoT support and add publish script

* 3.1.0-alpha.2

* edit publish command

* remove alpha tag

* remove auto-install and cleanup

* 3.1.0-alpha.3

* remove utils from publish command

* refactor(): remove some prefixes

* remove console logs

closes #1145

* chore(): merge master into v3-injectable (#1146)

* 2.5.0

* chore(): update changelog

* fix(pin-dialog): add missing errorIndex

* 2.5.1

* chore(): update changelog

* fix(zip): progress callback is optional (#1049)

* fix(apprate): add missing Windows Store option (#1072)

* Update file-chooser.ts (#1071)

Removed semicolon after .then() in usage instructions

* docs(device-motion): update interface names (#1076)

AccelerationData interface is wrongly named in docs. It should be DeviceMotionAccelerationData. And I added it to import statement.

* feat(inappbrowser): add interface for IAB options (#1065)

* Add InAppBrowserOptions Interface for better tooling.

* feat(inappbrowser): add  interface for IAB options

* Add more constructor tests.

* Add missing iOS options.

* docs(media): update method usage (#1089)

* fix(push): add the missing option clearBadge (#1087)

* docs(badge): fix example (#1096)

Error in code example (supplied parameters do not match call signature)

* fix(imagepicker): add outputType option (#1098)

* fix(facebook): fixes issue when not supplying default params (#1088)

* Fix default facebook logEvent parameters

* Implement correct parameters format in facebook logEvent method

* Update ibeacon.ts (#1099)

Return type of `getAuthorizationStatus()` made more explicit.

* fix(file): add missing exports (#1101)

Any declaration that is not being exported is missing from the resulting d.ts declaration files.

* Add InAppBrowserOptions interface to documentation. (#1103)

* Update sqlite.ts (#1106)

Added a bracket to remove the syntax error

* update device orientation docs to reflect renaming of CompassHeading interface (#1107)

* Move marker code inside MAP_READY (#1108)

The code to set the camera position and marker should be moved inside the function handling MAP_READY.  Otherwise they execute before the event is fired and it doesn't work.

* refactor(file): accept ArrayBuffer for data to write (#1109)

* docs(google-maps): fix param type

closes #1110

* fix(media): add missing pauseRecord and resumeRecord methods (#1122)

* docs(stripe): fix type and naming issues (#1129)

* refactor(paypal): fix type of items (#1125)

Type of items should be Array<PayPalItem> instead of string.

* fix(serial): Serial.requestPermission() options are optional (#1128)

* add success/error indices

* feat(browser-tab): add browser tab plugin (#1126)

* feature: added hasPermission function to Firebase fixes #1115

* feat: Implemented support for BrowserTab #1077

* docs(browser-tab): add proper docs

* fix(background-geolocation): configure returns a promise

closes #1118

* docs(background-geolocation): add return types and platforms

* fix(contacts): allow passing asterisk as contact field type

closes 1093

* fix(contacts): allow passing asterisk as contact field type

closes #1093

* fix(plugin): revert changes to support stable version (#1116)

 fix #1001

* feat(file): add system paths

* feat(app-update): add cordova-plugin-app-update support (#1105)

* add new app-update plugin

* update plugin info

* docs(app-update): add docs

* feat(alipay): add alipay support. (#1097)

* add cordova-alipay-base plugin. to support Alipay payment

* change ALI_PID to APP_ID, make it same with the latest SDK

* rewrite comments

* docs(google-maps): improve docs (#1095)

Move `map.moveCamera(position);` inside the MAP_READY event.
Allow to zoom the map on first launch (both iOS and Android).

* fix(file): remove FileError from return type (#1086)

Promises that reject with a `FileError` are not of the type `Promise<T|FileError>`, but `Promise<T>`.

The previous declarations of `Promise<T|FileError>` would break typing further down the chain where you are trying to use the value that the typing says could be `T|FileError` but in reality could only be `T`.

* feat(google-maps): add constant for map type

* fix(file): platform Browser will raise a an DOMException (#1082)

fix(File): Platform Browser will raise a an DOMException on resoleLocalFilesystemUrl and tries to write on readonly property DOMException err.message in fillErrorMessage

* feat(local-notifications): support for icon background color (#1079)

The Cordova plugin Ionic Natives uses allows specifying the background color of the smallIcon.  By not including it in your interface you force users to use the default color for their version of Android.  While the LocalNotification plugin is not well documented, it does include this feature, see Options.java line 253:

```
/**
     * @return
     *      The notification background color for the small icon
     *      Returns null, if no color is given.
     */
    public int getColor() {
        String hex = options.optString("color", null);

        if (hex == null) {
            return NotificationCompat.COLOR_DEFAULT;
        }

        int aRGB = Integer.parseInt(hex, 16);

        return aRGB + 0xFF000000;
    }
```

I've simply added the option to the interface as well as a short description.

This lets you go from the default color (varies by Android version): https://goo.gl/photos/nERcj4GZgapy8aee9
To any color you'd like: https://goo.gl/photos/t8V9WVba8jDU49aHA
And also works if you also specify a large icon: https://goo.gl/photos/gWQYwa12djmdXfYcA

* feat(unique-device-add): add UniqueDeviceId plugin (#1064)

* fix plugin

* feat(text-to-speech): Add stop method (#1063)

vilicvane/cordova-plugin-tts#32

* feat(appodeal): adds Appodeal SDK wrappers for iOS and Android (#1031)

* feat(Appodeal) bootrapping

* starting docs

* more docs

* feat(appodeal): add event Observables

* feat(appodeal): replace Cordova Observable events with #.fromEvent()

* feat(appodeal): update decorator metadata

* feat(couchbase-lite): add CouchbaseLite cordova plugin (#1025)

* feat(CouchbaseLite): add CouchbaseLite cordova plugin

* add plugin url

* feat(background-fetch): Adding Background Fetch requested in #990 (#1013)

* Adding Background Fetch (https://github.com/transistorsoft/cordova-plugin-background-fetch) requested in #990

* Adding BackgroundFetch to index

* feat(gyroscope): add Gyroscope plugin (#1004)

* add gyroscope.ts to plugins

* add gyroscope to index

* Update gyroscope.ts

* Update gyroscope.ts

* Revert "fix(File): typing where `FileError` can be thrown" (#1130)

* tslint and fix build issues

* 2.6.0

* chore(): update changelog

* fix(core): dont check if method exists when overriding

fixes #1043

* fix(file): fix writeExistingFile

closes #1044

* feat(diagnostic): add new methods

closes #1045

* feat(background-mode): replace event listeners with on method

The methods onactivate, ondeactive and onfailure no longer exist. You must now use `on` method.

* feat(background-mode): add missing functions

 closes #1078

* tslint

* set GoogleMapsMapTypeId to private

* remove beta from stripe

* 2.7.0

* chore(): update changelog

* feat(app-preferences): added cordova-plugin-app-preferences support (#1084)

* (feat) added cordova-plugin-app-preferences support

* replaced callback functions with promises

* updated example

* (feat) added cordova-plugin-browsertab support

* Revert "(feat) added cordova-plugin-browsertab support"

This reverts commit 00eb5cf.

* (update) synchronize fetch

* feat(photo-library): added cordova-plugin-photo-library (#1102)

* feat(photo-library): added cordova-plugin-photo-library

* CordovaFiniteObservable moved to photo-library.
Overloads are marked as private.

* refactor(photo-library): fixed circleci failing in 2.7.0 (#1132)

* feat(photo-library): added cordova-plugin-photo-library

* CordovaFiniteObservable moved to photo-library.
Overloads are marked as private.

* fixed typescript error in 2.7.0

* feat(health): add wrapper for cordova-plugin-health (#1039)

* feat(health): add wrapper for cordova-plugin-health

* fix(Health): add optional params to QueryOptions for .query()

* docs(health): fix javadoc of interfaces

* fix(health): remove unused Plugin option

* docs(health): add missing documentation

* doc(health): add promise to return

* doc(health): remove empty lines

* doc(health): Add description & reference to repo

* doc(health: add "return {Promise<any>}"

* refactor(safari-view-controller): hide returns promise

* fix typo in ibeacon plugin (#1138)

* fix(file): fix return types

fixes #1139

* docs(background-geolocation): fix param docs

* refactor(health): fix return types and prefix interfaces

* 2.8.0

* chore(): update changelog

* docs(sqlite): syntax error resolved (#1142)

* Syntax error resolved

The `{}` should be `[]`, but since there is no binding we do not get error. In case we add one, then the syntax will be incorrect.

* Fixed a syntax error

* fix(background-geolocation): configure returns an observable

* docs(): update docs

* 3.1.0-rc.1

* refactor(background-geolocation): update imports

* docs(background-fetch): fix return type

* docs(health): fix return type

* chore(CI): fixing npm install instructions in generated readmes

* set concurrency to number of cores

* chore(): update deps

* 3.1.0-rc.2

* chore(): update angular to 2.4.8

* 3.1.0-rc.3

* chore(): update angular to 2.4.8

* chore(): update rxjs to 5.0.1

* chore(): organize and enhance decorators (#1171)

* fix/add decorators

* fix google maps design

* chore(): add root tsconfig to resolve imports in IDE

* updates

* more fixes

* chore(): add options to InstanceCheck

* chore(decorators): promise is default for Cordova/Instance check

* chore(): add check decroators

* docs(): update plugin docs

* chore(decorators): fix cordovaCheck and instanceCheck

* 3.1.0-rc.4

* chore(docs): remove gitPackage from doc generator

* chore(docs): update to latest dgeni version

* fix diagnostic

* feat(media): create method now returns a promise

Breaking change: create no longer returns a MediaObject instance. Make changes to your app accordingly.

* docs update + remove any static methods/properties

* remove duplicate method

* remove extra docs

* remove extra docs

* docs(): rename plugins

* chore(decorators): do not check method name on instancecheck

* chore(decorators): do not check method name on cordovacheck

* chore(plugin): fix pluginWarn

* chore(plugin): fix pluginWarn

* fix(decorators): fix InstanceCheck decorator

* 3.1.0-rc.5

* chore(docs): fix readme generation

* fix(transfer): fix v3 implementation

* refactor(paypal): PayPal is brand name

* chore(docs): replace all spaces with dashes

* chore(): add dashify filter

* chore(build): add aot path to core tsconfig

* feat(action-sheet): add ANDROID_THEMES constant

* refactor(): general cleanup (#1193)

* feat(screen-orientation): update wrapper to match v2 of the plugin

The whole implementation has changed now. You must update your code.

* feat(stripe): add new methods

* feat(linkedin): add LinkedIn plugin

* 3.1.0-rc.6

* style(screen-orientation): double quote to single

* tslint

* refactor(pedometer): rename file to index
@MaxDaten
Copy link

MaxDaten commented Apr 19, 2017

Installed ionic-native in version 2.9.0 and updated the cordova-screen-orientation-plugin to 2.0.0 and im still getting this error.

TypeError: undefined is not an object (evaluating 'u[e].apply')

unminified:

TypeError: undefined is not an object (evaluating 'pluginInstance[methodName].apply')

I have to add: I installed via npm install ionic-native@2.9.0 and manually moved the content of the dist folder to the www/lib/ionic-native folder because the ionic-native-bower project is still outdated and I'm still struggling with the old, at least for me confusing, project structure of ionic with the node_module and www/lib by bower mixup.

EDIT:

Added a minimal example with the bug and step by step setup:

https://github.com/MaxDaten/ionic-native-screen-orientation-bug

@MaxDaten
Copy link

MaxDaten commented Apr 19, 2017

Switching cordova-plugin-screen-orientation to version 1.4.3 solved the problem.

> ionic plugin rm cordova-plugin-screen-orientation --save
> ionic plugin add cordova-plugin-screen-orientation@1.4.3 --save

Is it a bug with ionic-native or cordova-plugin-screen-orientation?

@adyngom
Copy link

adyngom commented Apr 30, 2018

This works for me, putting the logic into the initializeApp function makes sense since it is essential for this particular functionality to properly trigger. So inside of app.module.ts I have:

constructor(
    public platform: Platform, 
    public statusBar: StatusBar, 
    public splashScreen: SplashScreen,
    private screenOrientation: ScreenOrientation) {
    this.initializeApp();

    // used for an example of ngFor and navigation
    this.pages = [
      { title: 'Home', component: HomePage },
      { title: 'List', component: ListPage }
    ];

  }

initializeApp() {
    this.platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      this.statusBar.styleDefault();
      this.splashScreen.hide();
      // lock the screen orientation
      this.screenOrientation
      .lock(this.screenOrientation.ORIENTATIONS.PORTRAIT)
      .then(status => console.log(status))
      .catch (e => console.log(e));
      });
  }

My current version

ionic -v
3.20.0

@hakangoker
Copy link

hakangoker commented Jan 2, 2020

it would have been great to document the versions of the plugins or a copy of config section. is it screenOrientation4 or is it beta or 5. I have the same code as the guy Adyngom and it doesnt work. https://ionicframework.com/docs/native/screen-orientation I did evrything thats said here except I dont import beta ngx version. It works perfect with emulator -lc but doesnt work on device IOS android

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