ionic-team / ionic-team/ionic-framework

bug: ActionSheet button handlers do not execute in user-gesture, blocking Web APIs (share, clipboard, etc)

Đang mở
#21,607 7 bình luận 0 reaction 0 người được giao Xem trên GitHub
package: core type: bug
Ngôn ngữ chính
TypeScript
Star
52.7k
Fork
13.3k
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
51

Mô tả

# Bug Report

**Ionic version:**

[ ] **4.x**
[x] **5.x**

**Current behavior:**
Button handlers in ActionSheets do not allow user-gestures to successfully invoke Share, Clipboard or other Web APIs in PWA mode on iOS/Safari.

The browser does not appear to think that the event occurred because of a user gesture, and results in: `NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.`

**Expected behavior:**
The handler should execute in the same promise chain as the user gesture, so that native APIs and browser functionality can be used. Safari is apparently more strict about this.

**Steps to reproduce:**
Use the following code in an ActionSheet handler in an installed PWA on iOS:

```
return navigator.share({
text: 'How to implement the Web Share API and a fallback',
url: 'https://www.apple.com'
});
```

The same code works fine when executed directly from a button click in the page template, or other source.

**Related code:**

```
const actionSheet = await this.actionCtrl.create({
buttons: [{
text: 'Share',
icon: 'share',
handler: () => {
return navigator.share({
text: 'How to implement the Web Share API and a fallback',
url: 'https://www.apple.com'
});
}
}]
});
await actionSheet.present();
```

(Any chance we could get an updated stackblitz template for ionic 5? The above is for Ionic 4 :) )

```
insert short code snippets here
```

**Other information:**
Tested on several iOS devices/versions. All tested behaved the same way.

**Ionic info:**

```
sharktop:topdecked-unified lincoln$ ionic info

Ionic:

Ionic CLI : 6.9.2 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 5.2.2
@angular-devkit/build-angular : 0.1000.0-rc.5
@angular-devkit/schematics : 10.0.0-rc.5
@angular/cli : 10.0.0-rc.5
@ionic/angular-toolkit : 2.2.0

Cordova:

Cordova CLI : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : not available
Cordova Plugins : not available

Utility:

cordova-res : not installed
native-run : not installed

System:

Android SDK Tools : 26.1.1 (/Users/lincoln/Library/Android/sdk)
NodeJS : v12.13.0 (/usr/local/lib/node_modules/node/bin/node)
npm : 6.14.4
OS : macOS Catalina
Xcode : Xcode 11.5 Build version 11E608c

```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Start at the ActionSheet button-handler entry point and reproduce the navigator.share example in an installed iOS PWA. Trace how the handler is invoked relative to the original user gesture, then verify completion with the reported Share or Clipboard Web API scenario without breaking normal ActionSheet handlers.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
typescript
Lĩnh vực
frontend, mobile-dev
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.