Meet Safari Web Extensions on iOS

RSS for tag

Discuss the WWDC21 session Meet Safari Web Extensions on iOS.

View Session

Posts under wwdc21-10104 tag

35 Posts
Sort by:
Post not yet marked as solved
0 Replies
286 Views
I have converted my chrome extension to Safari and followed all the instructions: here is my manifest: {  "manifest_version": 2,  "default_locale": "en",  "name": "__MSG_extName__",  "version": "1.0",  "homepage_url": "https://mydomain.com/",  "description": "__MSG_appDesc__",  "icons": {   "16": "images/16.png",   "32": "images/32.png",   "48": "images/48.png",   "128": "images/128.png"  },  "background": {   "scripts": [ "background.js"],   "persistent": false  },  "permissions": ["storage", "tabs", "contextMenus", "nativeMessaging", "<all_urls>"],     "browser_action" : {  "default_icon" : "images/_48.png",  "default_title" : "MyAppName v0.0.1" ,  "default_popup" : "popup.html"  },        "content_scripts": [ { "matches": ["<all_urls>"], "js": ["js/content.js"], }  ] } I've removed everything from background.js and left the below lines for troubleshooting: var bkg = chrome.extension.getBackgroundPage(); bkg.console.log("test1"); console.log("test2"); But I see no output. The same works for Safari macOS. I'd like to know if background.js would ever work in iOS? if yes, what do I need to do to get it working?
Posted Last updated
.
Post not yet marked as solved
0 Replies
384 Views
Hello, With iOS 15, we can now convert WEB extensions into APP extensions. But does all the functionnalities available in a WEB extension are still available when I convert it to an APP extension ? For example on MacOS, with a WEB extension, if I select a word or a sentence in Safari, I can display a button next to the text, that will allow me to launch an action. Will I be able to do the same with an iOS app extension ? (ie: display my own button when the user select a word or a sentence while browsing Safari on his phone) Thank you in advance for your help. Patrick
Posted Last updated
.
Post not yet marked as solved
0 Replies
375 Views
If someone installs the iOS extension and hasn't enabled it in safari settings, I want to alert/remind them to enable it when they open my website on Safari. So, if the user opens my website, can it detect that the iOS extension if it is already installed? One of the solutions I tried is to set a cookie or modify content on my website from iOS extension, but without enabling the iOS extension, it is not possible. Any help would be highly appreciated, thanks for your time!
Posted
by newbie658.
Last updated
.
Post marked as solved
2 Replies
665 Views
What are the correct sizes and colours to provide for the toolbar icon of a Safari Extension on iOS? For the size I tried creating a solid black icon and measuring the size. They seem to render at 24x24pt but providing 24px, 48px, and 72px images still look blurry. This also only covers the default text size; the icons scales with the system text size. The MDN documentation (which I cannot link here) says that an SVG can be used but supplying an SVG displays the app icon instead. The example icons are all black (like other toolbar icons on iOS) but when displayed in dark mode they are still black, which does not match the other icons in the list. Do I need to specify black and white icons? I tried using browser_action's theme_icons but they seem to be ignored. I've seen other solutions to switch out the icon at runtime but that requires a content script to be injected in to every page or for the popup to be opened by the user. iOS is already tinting the icon blue when the extension is active, can it tint it white when inactive in dark mode?
Posted Last updated
.
Post not yet marked as solved
2 Replies
1k Views
I am currently developing a safari web extension on iOS. The following piece of code is executed in the native application when the extension sends a message to the native app using browser.runtime.sendNativeMessage.    func beginRequest(with context: NSExtensionContext) {     let item = context.inputItems[0] as! NSExtensionItem     let message = item.userInfo?[SFExtensionMessageKey]     os_log(.default, "Received message from browser.runtime.sendNativeMessage: %@", message as! CVarArg) //    Message should follow format of: //    { //     type: "Message type", //     payload: "Message Payload" //    } //    In the future we may want to parse the payload differently, but for now it is a string     guard let response = message as? [String : AnyObject] else {       return     }     guard let type = response["type"] as? String else {       return     }     guard let payload = response["payload"] as? String else {       return     }           let res = NSExtensionItem()           if type == "COPY" {       let itemToCopy = [payload]       let pasteboard = UIPasteboard.general       pasteboard.strings = itemToCopy       res.userInfo = [ SFExtensionMessageKey: [ "res": true ] ]     }     context.completeRequest(returningItems: [res], completionHandler: nil) The code works flawlessly in the iOS 15 simulator, however it does not work on the actual device. ( iPod Touch 7th Generation running iOS 15 beta 2 ) There are no errors, it behaves as if it was working as expected. Any help would be greatly appreciated.
Posted
by uzinator.
Last updated
.
Post not yet marked as solved
0 Replies
427 Views
Feedback Assistant case: FB9545798 Installation and running git clone git@github.com:birchill/10ten-ja-reader.git cd 10ten-ja-reader yarn install npm run build:safari Now open "xcode13/10ten Japanese Reader.xcodeproj". For all four build targets, change the developer team to your own developer team. Run the build target named "10ten Japanese Reader Extension (iOS)" on a real device (mine is an iPhone 11 Pro), selecting the app "Safari" to run the extension for. Next, on your iPhone, go into Settings > General > Safari > Extensions and allow the extension named "10ten Japanese Reader". Return to iOS Safari, refresh the current tab (if you want a consistent URL to test on, then let's choose https://ncode.syosetu.com/n4830bu/130/), and check the Share sheet. Expected results A Web Extension named "10ten Japanese Reader" or similar should appear in the Safari Share menu. You should be able to enable it, and something that looks like a hockey puck will immediately appear in the bottom-right of the web page. Actual results Although I was able to run this Web Extension just fine on iOS 15 beta 5, since updating to iOS 15 beta 6 (and the corresponding latest macOS and Xcode betas available at the time of writing), I have been unable to run the Web Extension. That is to say, it does not appear in the Share menu, even though it appears in Settings > General > Safari > Extensions and is allowed. I have tried restarting both my Mac and my iPhone, and incrementing the build number, doing clean builds, etc., but nothing has helped. I see no debug in Xcode that gives any clues, either.
Posted Last updated
.
Post not yet marked as solved
0 Replies
370 Views
The 'Sea Creator' sample app demonstrating Safari Web Extensions first fails to compile, because due to disambiguation extension bundle id isn't prefixed with app bundle id. When fixed by changed ids the app fails on start, with error saying that the app can't find extension. Regardless, extension works on its own in Safari, but can't communicate with the host app due to aforementioned error.
Posted Last updated
.
Post marked as solved
1 Replies
933 Views
I have a very basic extension with manifest_version: 3 I tried to convert it through safari-web-extension-converter but it failed to convert with the error unable to parse the manifest.json. I changed the version to 2 and it worked perfectly. Is there no compatibility for manifest version 3 extension conversion? I checked the Assessing Your Safari Web Extension’s Browser Compatibility article, but it had no mentions regarding the manifest version 3 incompatibility. Is there something else, that I could be missing? and is this documented somewhere else? My system info: macOS 11.4 Big Sur XCode 13.0 beta 3 Thanks
Posted
by AjeetRE.
Last updated
.
Post not yet marked as solved
0 Replies
409 Views
Hello, I'm experimenting with the new Safari web extensions for iOS and iPadOS 15 but I'm hitting a wall when I try to execute a fetch request from the Web Extension Handler on a persistent store located in my app group container. First of all, I have not found a good way to debug my extension native code from XCode so I want to ask if someone is aware of a way to debug or having crash logs regarding those extensions. Regarding the CoreData issue, I can access the persistent store (checked with NSFileManager) in the group container and initialize my core data stack, but a simple fetch request without a predicate seem to result in a "no-response" error in the background script, possibly related to native code crash. The same code is run on another extension (Shortcuts) without problems. At this point in my testings, I'm unsure I took the wrong path and CoreDate can't be used by design, this is a beta bug or I'm missing something. Any clue is more than appreciated. I have run my test mostly on iPadOS 15 latest beta release.
Posted
by neos180.
Last updated
.
Post not yet marked as solved
3 Replies
973 Views
How can I download safari-technology-preview-125? when I click on the link(https://webkit.org/blog/11680/release-notes-for-safari-technology-preview-125/), I can download latest version which need macOS 12. however I have macOS 11.4 and need to debug my app && need all tab available in safari inspector.
Posted
by saeedeh21.
Last updated
.
Post not yet marked as solved
1 Replies
613 Views
Is it possible to send messages between the container app and the extension when working with an iOS Safari Web Extension? It seems to work ok on MacOS, but I can't find any documentation on how this would work on iOS. Any help would be greatly appreciated.
Posted Last updated
.