Skip to content

Commit

Permalink
Merge pull request #13105 from keymanapp/change/ios/report-host-app-i…
Browse files Browse the repository at this point in the history
…dentifier

change(ios): set host-app bundle identifier in embedded Web debug-report
  • Loading branch information
jahorton authored Feb 3, 2025
2 parents 06991a1 + 5b4df8e commit 8f89e70
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class KeymanWebViewController: UIViewController {
webView!.backgroundColor = UIColor.clear
webView!.navigationDelegate = self
webView!.scrollView.isScrollEnabled = false

if #available(iOSApplicationExtension 16.4, *) {
if(Version.current.tier != .stable) {
webView!.isInspectable = true
Expand Down Expand Up @@ -600,6 +600,10 @@ extension KeymanWebViewController: KeymanWebDelegate {
os_log("%{public}s", log: KeymanEngineLogger.engine, type: .info, message)
SentryManager.breadcrumb(message, sentryLevel: .debug)

// Overwrites the baseline "embeddingApp" text available before Web engine init with the
// active bundle identifier.
webView!.evaluateJavaScript("setHostAppName(\"\(Bundle.main.infoDictionary!["CFBundleIdentifier"]!)\")")

self.setSentryState()
resizeKeyboard()

Expand Down Expand Up @@ -696,7 +700,7 @@ extension KeymanWebViewController: KeymanWebDelegate {
// MARK: - Manage views
extension KeymanWebViewController {
// MARK: - Sizing

@objc func menuKeyHeld(_ keymanWeb: KeymanWebViewController) {
self.delegate?.menuKeyHeld(self)
}
Expand All @@ -713,10 +717,10 @@ extension KeymanWebViewController {
let width: CGFloat
width = UIScreen.main.bounds.width
var height: CGFloat

// get orientation differently if system or in-app keyboard
let portrait = Util.isSystemKeyboard ? InputViewController.isPortrait : UIDevice.current.orientation.isPortrait

/**
* If keyboard height is saved in UserDefaults, then use it
*/
Expand All @@ -728,17 +732,17 @@ extension KeymanWebViewController {
*/
height = self.determineDefaultKeyboardHeight(isPortrait: portrait)
self.writeKeyboardHeightIfDoesNotExist(isPortrait: portrait, height: height)

/**
* If we need to write out the keyboard height for one orientation, then we
* expect that the other must be written also.
* expect that the other must be written also.
* Write it out now, but only if a value for keyboard height does not already exist.
*/
height = self.determineDefaultKeyboardHeight(isPortrait: !portrait)
self.writeKeyboardHeightIfDoesNotExist(isPortrait: !portrait, height: height)
}
/**

/**
* no need to check for Util.isSystemKeyboard because this is shared storage
* the UserDefaults are readable and writeable by both system and in-app
*/
Expand Down Expand Up @@ -768,7 +772,7 @@ extension KeymanWebViewController {

return height;
}

/**
* Write out the keyboard height to the UserDefaults but only if it does not exist there yet.
* If it exists, then we assume it was configured by the user and do not want to
Expand All @@ -789,7 +793,7 @@ extension KeymanWebViewController {
}
}
}

var keyboardSize: CGSize {
get {
if kbSize.equalTo(CGSize.zero) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ function setKeymanLanguage(stub) {
});
}

function setHostAppName(name) {
// Sentry will capture this in a breadcrumb for Web errors.
keyman.config.embeddingApp = name;
}

var fragmentToggle = 0;
/**
* Inserts the selected string <i>s</i>
Expand Down
4 changes: 4 additions & 0 deletions web/src/app/webview/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export class WebviewConfiguration extends EngineConfiguration {
return this._embeddingApp;
}

set embeddingApp(name: string) {
this._embeddingApp = name;
}

get oninserttext() {
return this._oninserttext;
}
Expand Down

0 comments on commit 8f89e70

Please sign in to comment.