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

Make web views inspectable #1286

Merged
merged 3 commits into from
Aug 8, 2023
Merged

Make web views inspectable #1286

merged 3 commits into from
Aug 8, 2023

Conversation

casey-chow
Copy link
Contributor

@casey-chow casey-chow commented Jul 27, 2023

Description

One Line Summary

Adds Safari inspectability for all WKWebView instances, closes #1277. See https://webkit.org/blog/13936/enabling-the-inspection-of-web-content-in-apps/ for details.

Details

Motivation

This PR allows developers to view WKWebView instances inside Safari's inspection mechanism for iOS devices. This is necessary for us to verify click tracking in OneSignal Web Views.

Testing

No automated testing added since this is functionally a configuration change.

Manual testing

I've not been able to succeed testing this, seems like the framework cannot be built without certificates.

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
    • If it is hard to explain how any codes changes are related to each other then it most likely needs to be more than one PR
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
    • Simplify with less code, followed by splitting up code into well named functions and variables, followed by adding comments to the code.
  • I have reviewed this PR myself, ensuring it meets each checklist item

This change is Reviewable

Copy link
Contributor

@emawby emawby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello thank you for your contribution! It looks like this is failing to build. I believe the Objective-C version of this property is named inspectable (the getter is isInspectable)

@casey-chow
Copy link
Contributor Author

Hello thank you for your contribution! It looks like this is failing to build. I believe the Objective-C version of this property is named inspectable (the getter is isInspectable)

Awesome, thanks! I pushed a fix, do you have guidance about getting this to build in an existing project? I wasn't able to due to certificate signing issues.

@emawby emawby self-requested a review July 31, 2023 16:38
Copy link
Contributor

@emawby emawby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question you likely need to change the bundle id and development team in the dev app. One last fix

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @casey-chow, @jkasten2, and @rgomezp)


iOS_SDK/OneSignalSDK/Source/OneSignalWebView.m line 45 at r1 (raw file):

    _webView.navigationDelegate = self;
    // https://webkit.org/blog/13936/enabling-the-inspection-of-web-content-in-apps/
    if (@available(macOS 13.3, iOS 16.4, *)) {

Let's add a condition to this to only enable inspectability if the app is being run in debug mode.


iOS_SDK/OneSignalSDK/Source/OSInAppMessageView.m line 114 at r1 (raw file):

    self.webView.opaque = NO;
    // https://webkit.org/blog/13936/enabling-the-inspection-of-web-content-in-apps/
    if (@available(macOS 13.3, iOS 16.4, *)) {

Let's add a condition to this to only enable inspectability if the app is being run in debug mode.

@casey-chow
Copy link
Contributor Author

Let's add a condition to this to only enable inspectability if the app is being run in debug mode.

The main issue I'm facing is our web developers are facing issues in the production version of the app, so we'd like to have access in TestFlight. This is especially important because we need to test against production data/non-sandbox environment, which we can't on a debug build. The other option would be to expose this configuration in the API, but I opted to avoid making any API changes.

Copy link
Contributor

@emawby emawby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense in order to allow debugging in TestFlight lets have the condition be OneSignal's log level as debug or higher. I do not want to have inspectability on by default. This behavior would also match the Android SDK's Webview inspectability behavior.

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @casey-chow, @jkasten2, and @rgomezp)

@casey-chow
Copy link
Contributor Author

@emawby made the requisite changes, please take a look!

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

Successfully merging this pull request may close these issues.

[Bug]: Web Push templates are not inspectable in Test Flight
3 participants