nativescript-community / perms

An unified permissions API for NativeScript on iOS and Android.
https://nativescript-community.github.io/perms/
Apache License 2.0
12 stars 9 forks source link

Notification permission is not shown when app is reinstalled (iOS) #9

Closed kanclalg closed 2 years ago

kanclalg commented 2 years ago

Notification permission prompt is only shown once on a device per app. When I delete the app and install again notification prompt is not shown and notification settings are not available in app settings though request returns authorized. Tried to create multiple test apps - all resulted the same.

iOS 15.4

farfromrefug commented 2 years ago

@kanclalg not sure what s happening but it seems impossible. If you delete the app all permissions are lost. I cant tell you much more than this. You need to debug this and see what s really going on. But the theory is that it is impossible!

kanclalg commented 2 years ago

@farfromrefug let's not go to possible, not possible conclusions before actually trying to reproduce it.

I've debugged it to this line https://github.com/nativescript-community/perms/blob/master/src/permissions.ios.ts#L419 It returns true here for isEnabled

Tested again on a new app: it went straight to that line and returned true. No prompt was shown at any time this time.

Test app: TestNotification.zip

I'm using https://www.npmjs.com/package/@nativescript/local-notifications now for requesting permission. It works fine.

farfromrefug commented 2 years ago

@kanclalg OK but then it is not the issue you mentioned before? it never prompts? even on first run ? what I said was impossible was if it worked once but then kept returning true after re installation

kanclalg commented 2 years ago

It might have been some clash with other libs before, I'm not sure now really. Let's stick for now that it always returns true.

farfromrefug commented 2 years ago

@kanclalg thanks for reporting this. Could you try 2.2.8 ?

kanclalg commented 2 years ago

still nothing. Getting [undetermined, true] now.

Screen Recording 2022-06-30 at 17.40.47.zip

farfromrefug commented 2 years ago

@kanclalg ok i ll investigate further

farfromrefug commented 2 years ago

@kanclalg should be fixed in 2.2.9

kanclalg commented 2 years ago

Crashes on request:

(UserNotifications) [com.apple.UserNotifications:Connections] [org.nativescript.TestNotification] Getting notification settings (async)
====== Assertion failed ======
Native stack trace:
1          0x10a2335dc tns::Assert(bool, v8::Isolate*) + 125
2          0x10a252b36 tns::Interop::WriteValue(v8::Local<v8::Context>, tns::TypeEncoding const*, void*, v8::Local<v8::Value>) + 5318
3          0x10a251548 tns::Interop::SetFFIParams(v8::Local<v8::Context>, tns::TypeEncoding const*, tns::FFICall*, int, int, tns::V8Args&) + 110
4          0x10a2511b2 tns::Interop::CallFunctionInternal(tns::MethodCall&) + 420
5          0x10a1b9a32 tns::ArgConverter::Invoke(v8::Local<v8::Context>, objc_class*, v8::Local<v8::Object>, tns::V8Args&, tns::MethodMeta const*, bool) + 736
6          0x10a20dc82 tns::MetadataBuilder::InvokeMethod(v8::Local<v8::Context>, tns::MethodMeta const*, v8::Local<v8::Object>, tns::V8Args&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool) + 76
7          0x10a20d57e tns::MetadataBuilder::MethodCallback(v8::FunctionCallbackInfo<v8::Value> const&) + 222
8          0x10a34758e v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) + 606
9          0x10a346a17 v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) + 727
10         0x10a345f6f v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) + 255
11         0x10ab04619 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit + 57
JavaScript stack trace:
(UserNotifications) [com.apple.UserNotifications:Connections] [org.nativescript.TestNotification] Got notification settings [ hasResult: 1 hasCompletionHandler: 1 ]
at observer (file: src/webpack:/TestNotification/node_modules/@nativescript-community/perms/permissions.ios.js:457:59)
farfromrefug commented 2 years ago

@kanclalg could you try with @nativescript/ios versin 6.5.5 (clean your platforms dir). I suspect a crash in the v8 runtime (which i dont use)

NathanWalker commented 2 years ago

@kanclalg it's not a v8 issue at all. The result is processed on background thread:

Main Thread Checker: UI API called on a background thread: -[UIApplication registerForRemoteNotifications]

I can help make adjustment. Keep in mind 6.5.5 is JSC runtime and it cheated on several things which lead to misunderstandings in how platform interaction should work.

farfromrefug commented 2 years ago

@kanclalg please try latest version