iOS : Notification and Calendar permission issue resolution#2833
iOS : Notification and Calendar permission issue resolution#2833kumarpalsinh25 merged 2 commits intomainfrom
Conversation
|
Hey there 👋,
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2833 +/- ##
==========================================
+ Coverage 36.55% 36.57% +0.01%
==========================================
Files 831 831
Lines 52442 52441 -1
==========================================
+ Hits 19171 19180 +9
+ Misses 33271 33261 -10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| final deviceCalendar = DeviceCalendarPlugin(); | ||
| final hasPermission = await deviceCalendar.hasPermissions(); | ||
| return hasPermission.data ?? false; |
There was a problem hiding this comment.
This permission checking was managed by device_calendar code which was always buggy and not giving proper status so I replaced it with permission_handler which we are using in other places of the app as well.
There was a problem hiding this comment.
Where does this idea that "device_calendar code which was always buggy" come from? It worked fine for at least a bunch of cases, including some iOS testing (I had done here before). Replacing this raises the question: has this been tested on other platforms than iOS? And: is this change really necessary for the fix?
gnunicorn
left a comment
There was a problem hiding this comment.
I don't understand what the actual problem was nor how these things are supposed to fix them.
The calendar events plugin request used to work fine, replacing it without a good reason risks us breaking several other cases that worked before. And the additional supposed settings have already been set in the Info.plist.
What actually is the issue and what change in here fixes it? Additionally: has this been tested on other supported platforms?
| final deviceCalendar = DeviceCalendarPlugin(); | ||
| final hasPermission = await deviceCalendar.hasPermissions(); | ||
| return hasPermission.data ?? false; |
There was a problem hiding this comment.
Where does this idea that "device_calendar code which was always buggy" come from? It worked fine for at least a bunch of cases, including some iOS testing (I had done here before). Replacing this raises the question: has this been tested on other platforms than iOS? And: is this change really necessary for the fix?
| target.build_configurations.each do |config| | ||
| # You can remove unused permissions here | ||
| # for more information: https://github.com/Baseflow/flutter-permission-handler/blob/main/permission_handler_apple/ios/Classes/PermissionHandlerEnums.h | ||
| # e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0' | ||
| config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [ | ||
| '$(inherited)', | ||
| ## dart: PermissionGroup.calendar | ||
| 'PERMISSION_EVENTS=1', | ||
|
|
||
| ## dart: PermissionGroup.calendarFullAccess | ||
| 'PERMISSION_EVENTS_FULL_ACCESS=1', | ||
|
|
||
| ## dart: PermissionGroup.notification | ||
| 'PERMISSION_NOTIFICATIONS=1', | ||
| ] | ||
| end |
There was a problem hiding this comment.
Is this the actual fix then? I don't understand why this would fix anything. Clearly notifications worked before without this, so whatever this is doing, it isn't overwriting the Info.plist settings. And as said before, the same is true for calendar events - it is used to work fine before, why is this necessary now?
I think this requires more documentation than a link to a list of things, like maybe a github issue or readme describing that doing this is necessary?!?
There was a problem hiding this comment.
there is a huge explanation but I still don't know where this code comes from. It is not on the permission_handler setup README as implied. If this is not the setup usually needed for permission_handler, why do we need it?
|
To understand and fixed the issue, I need to dd bit of R&D and then implemented this code. Let me try to explain everything address your queries. General Awareness:Now a days, all plugins are managing permission handling as built in part of it. Like camera, photos, calendar, notification etc permissions are managed by their respective plugins. Permission Handler:
Side-notes:
Current Issue Point:Ref : Comment
Answer:
Permission handler for calendar permission:Ref : Comment
Answer:
Additional Platforms Things:Ref Comment:
Reference Video:
Issue.Point.mov
Expected.Behavior.When.permissioned.enabled.mov |
|
When I am asking about "what is the actual issue", I didn't mean to expand on the large parts of the ins and outs, but that
is the actual interesting part - yet it lacks a link. Is there some issue on their repo or a link of their code or anyone else explaining the bug? I can't find any in their repo. So if not, what's the evidence for a bug in their code and not ours? If there is a bug there and it isn't reported yet, why don't we report it?
But this PR changes that. It changes the code that is run on Android to one we haven't used there before. So it hasn't been tested whether the new code works on Android then? Why not? I am not suggesting it doesn't work. But it code effecting both platforms and it is kinda critical for the calendar sync to work. So if we changed it to fix it one platform, we still need to confirm whether that new code works on the other as well... |
|
To be clear, I am not claiming it doesn't fix the bug in question, nor am I suggesting this is wrong code. What I am asking why does it fix it. And I have troubles understanding two concrete parts, not the big picture:
Neither of these two specific remarks has been addressed. |
Sorry but I am not getting you. Isn't video shown in this issue #2820 enough to get idea of issue?
I just come across issue on Monday my iPhone and felt that will block things so before next Thursday release I want to fix it without waiting from other people to report and then resolve the issue. It was all about permission checking so used permission_handler.n. I didn't had any other solution to move on with this bugs solition.
Yes of course, tested new code with android. If want then will share video reference of the same. (Side-not : This is just simple permission checking code that's why haven't shared android video reference in PR Description but happy to share that)
I am getting difficulty in explaining things in words. If you can just test Notification and Calendar permission scenarios with Granted, Denied and PermanentlyDenied cases then probably you will get better understanding on what wrong on what things and what can be solution. Also sharing again, I have tested code on Android and iOS both platforms.
It is clearly mentioned on https://pub.dev/packages/permission_handler document about configuration requirement. |
Ah, sorry, my bad. It is behind an expand so even a ctrl+f on the page doesn't find it unless you opened it. Okay, great, that's all I wanted to know!
No, need. All I asked was whether it was tested on Android and didn't get a straight answer. If you say you did, that's enough for me.
So... I am only talking about the The answer is no. Digging deeper into the issue, finding the reference in the changelog of permissions handler of permission changes for calendar by apple in iOS 17+, which lead me to this bug report on device calendar for which there seem to be a fix, which just hasn't been merged due to support for older iOS. Arguably, we could probably just use that fix, as we don't intend to support iOS 13, but this is what I call the root cause -- the evidence. There is a bug in device calendar and there is a report and even a fix for it. This is our problem. Now, you chose the path to go over flutter permissions handler instead which has wider and better support, and that is fine. I was only lacking context for the specific change in question. |

Fixes, #2820
As we are using permission_handler for permission checking and management, based on their official documentation, we need to declared permissions thing in
iOS/Podfileto make it work properly.If we don't declared it it library will alway given
permissionDeniedstatus which was the core issue in our code.