Closed cfjedimaster closed 7 years ago
Same issue here.
Angular 2 final.
@cfjedimaster
I executed demo from this repository and It works nice. Check your Manifiest.xml. I have permissions in it but they don´t appear in settings -> apps -> your app -> permissions. They don´t in my case but they do in the demo.
So I think it is a Nativescript or Nativescript-angular issue,
So for me, it was a few things. Doing a proper build sorted me not getting prompted. But I still get undefined if I console.log(android.Manifest). Should it exist? Things seemed to work despite that, but it's like undefined in JavaScript.
@cfjedimaster
Show your AndroidManifest.xml from app/App_Resources/Android
I made a mistake because I edited AndroidManisfest from platformst and that Manifest is override in compilation. Now It works.
Can you confirm your AndroidManifest.xml from platforms is override in compilation?
Yep
Same Issue I always get "Uh oh, no permissions - plan B time!".
permissions.requestPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) .then(function() { console.log("Woo Hoo, I have the power!"); }) .catch(function( ex ) { console.log("Uh oh, no permissions - plan B time!" ); });
Ok, a couple things to verify:
/app/App_Resource/Android/AndroidManifest.xml
ngOnInit
in a NG app? I'll have to test; this might too early in the bootstrap. I've always put it in the onNavigatedTo
event of the first or relevant window.declare var android: any;
at the top of the file. Anything else and you are asking for issues.2) So... this kinda concerns me. From my Cordova experience, I know I have to wait for the deviceready event when doing 'hardware' stuff. I thought NS didn't have this issue? Is there a similar concept in NS that I'm just not aware of - if so - where is this documented?
@NathanaelA
I have no issues. It was my mistake. All work nice for me.
@cfjedimaster - Actually it is just like an native android app; if you do somethings to early (i.e. no activity
created yet) then it has issues, if it has to have an activity
and/or context
for the code to run under.
Ok.so I don't want to go OT on this bug thread, but is there a general doc page that discusses this?
On Mon, Oct 3, 2016 at 11:36 AM, Nathanael Anderson < notifications@github.com> wrote:
@cfjedimaster https://github.com/cfjedimaster - Actually it is just like an native android app; if you do somethings to early (i.e. no activity created yet) then it has issues, if it has to have an activity and/or context for the code to run under.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/NathanaelA/nativescript-permissions/issues/18#issuecomment-251156317, or mute the thread https://github.com/notifications/unsubscribe-auth/AAYBvBJRMcTBcWmw44z7oJeIEe5RlEusks5qwS7wgaJpZM4KJBwm .
Raymond Camden, Developer Advocate for StrongLoop at IBM
Email : raymondcamden@gmail.com Blog : www.raymondcamden.com Twitter: raymondcamden
Hi, I have the same issue. I'm using typescript with angular2 and when i tried to use android.Manifest its undefined... I have included android17.d.ts
For plain js project its working...
@NathanaelA Thank you for your quick response, I changed the manifest and added the permission there, Then everything worked fine and i got the messege "Woo Hoo, I have the power!" in the console but no promt for asking permission I am using angular 2 with type script, android 6 on galaxy s7 edge
@yazdkhasti - Some permissions you do not need to actually ask for permission; they are granted as long as they are in the manifest, only some permissions will require the user to accept the permission at runtime.
For clarity for each of these issues:
declare var android: any;
this fixes the typescript compile complaining about android
not being defined: see my blog post for more info: http://fluentreports.com/blog/?p=308/app/App_Resources/Android/AndroidManifest.xml
For some reason, android.Manifest does not exist. I'm testing like so:
console.log(JSON.stringify(android.Manifest));
And I never get the request. This is in ngOnInit.