Create a submodule (so folks can turn it off when not required or when Apple goes more mainstream with their PWA support) to emit the following meta info in
<link rel="apple-touch-icon" sizes="192x192" href="/img/icons/app-icon-192.png">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="theme-color" content="#ffffff" />(port that last one over from main module)
For context, quoting from comments by #MrPaulDriver and others in #3060759: Fully working D8 version based on D7 Serviceworker:
If we decide on a metatag sub-module, it might also be worthwhile providing some optional iOS optimisations for PWAs
This allows iOS devices to run PWAs in full screen mode. The reason I say this should be optional, is because iphones do not have a back button, and it is therefore necessary to incorporate some UI in an app to enable backward navigation. The latest version of iOS Safari supports forward and backward swipe gestures, an indication perhaps that Apple are starting to recognise PWA's as a thing.
Another iOS metatag controls the appearance of the status bar. I am still experimenting with this and have yet to form an opinion about how important it is.
References:
https://developers.google.com/web/updates/2015/08/using-manifest-to-set-...
https://developer.apple.com/library/archive/documentation/AppleApplicati...
https://medium.com/appscope/designing-native-like-progressive-web-apps-f...
So, a bit of reading up confirms that add to home screen is supported by iOS (and always was). But iOS does not use the icon referenced in the manifest file. A workaround is needed.
https://www.google.com/search?q=progressive+web+app+apple+touch+icon
| Comment | File | Size | Author |
|---|---|---|---|
| #34 | interdiff-3066848-27-34.txt | 3.38 KB | alexborsody |
| #34 | 3066848-34.patch | 10.43 KB | alexborsody |
Comments
Comment #2
mrpauldriver commentedFor discussion, I'd just like to add that iOS also has it's own (long standing) method for providing a launch screen which is also facilitated by metatags. It's rather long winded but works quite well.
The code below is added to the head.
A number of online services exist which make the generation of device specific images fairly straight forward. I used this one.
I found that uploading a 512x512 pixel image produced a comparable splash screen to the one which is (sometimes) presented by Chrome.
Comment #3
mrpauldriver commentedCross referencing with https://www.drupal.org/project/pwa/issues/3074111 where @zenimagine correctly notes that the absence of an apple-touch-icon is now called out by a recent update to Chrome Lighthouse.
Comment #4
alexborsody commentedTry this patch, it includes the submodule `pwa_meta_tags` all metatags are controlled there, let me know any feedback.
Comment #5
alexborsody commentedComment #6
alexborsody commentedActually I noticed an issue with this on installation, will fix it.
Comment #7
mrpauldriver commentedWSOD after enabling the module.
Error: Unsupported operand types in pwa_meta_tags_page_attachments() (line 18 of /Users/paul/Sites/drupal8test/public_html/web/modules/contrib/pwa/pwa_meta_tags/pwa_meta_tags.module) #0Comment #8
alexborsody commentedYes noticed that too with the simplytest.me link after I uploaded the patch, try this.
Comment #9
alexborsody commentedComment #10
naveenvalechaThanks for your contribution. Great work!
I have reviewed the patch from the high-level.I'm planning to use this sub-module in an upcoming project. I would be able to provide more feedback when we will leverage it in the project.
Add new line at end of the file
Ditto as above. Add new line at EOF
It would not be required. enforced dependency of the configuration on the module would delete the configuration
Can you define a new menu link in the pwa module and make the metatag configuration under /admin/config/pwa
Move this to pwa module
Add newline at EOF
The permission has been removed. Please use "access content"
Change the route and put it under the admin/config/system/pwa if the maintainer agrees on the creating a dedicated menu for the PWA
administer pwa
Remove it
Remove the space and from all other places in the file.
Rename the form key to express what's it is for?
Why there's not any title of these checkbox? Please add a comment.
Define the defination of these properties in the config/schema/pwa_meta_tags.schema.yml
Comment #11
alexborsody commentedThanks naveenvalecha, please feel free to reroll the patch and post it here, otherwise I will get to it soon.
Comment #12
naveenvalechaI have some time today. I could address above. Assigning to myself for that.
Comment #13
mrpauldriver commentedThis is looking great.
1.) Just peeking at the generated mark-up and see that image paths currently point at
/user/touch-icon-iphone.pngrather than/sites/default/files/pwa- As a work in progress I guess you are aware of this and I mention it only in case it is a bug.2.) Field group title 'APPLE ADD TO HOMESCREEN ICONS' should probably be 'APPLE LAUNCH SCREEN IMAGES'. I say launch screen rather than splash screen because this is what Apple call them.
Is the plan to generate all the various icons and launch screen images from the pwa settings image? Or just to implement the meta tags, with image creation being the responsibility of the site builder?
If this is to be left to site builders we should add some help text.
Edited
Comment #14
alexborsody commentedI was thinking the sitebuilder can just drop the icons into the root directory or whatever folder we decide on, probably the simplest solution for everyone, agree help text is needed.
But if someone wants to build an image upload/generation that works flawlessly, that could be cool too.
Comment #15
mrpauldriver commentedI tend to think that image generation for touch icons would not be much different to existing functionality. Launch screens would be more involved though.
Given that PWA module already creates a folder at
/sites/default/files/pwa, I would have thought this ought to be the default location. Any reason why this should not be so?Comment #16
alexborsody commentedI don't have a reason other than I don't think it's a top priority right now, also it just adds another layer of complexity to maintain and dropping in images manually seems easy for anyone technical enough to SFTP which I think is most Drupal users. I agree with you though that it's better to have than not to.
Comment #17
naveenvalechaHere's the patch which accommodated #10. Also, I renamed the module from the pwa_meta_tags to pwa_ios as it is specific to the IOS.
There's still a lot of clean up required before it gets in. Please find the attached interdiff to see what changes have been made between two patches.
Next Items:
- Address the #13
- More cleanup
If anyone wants to take it up before I address it feel free to take it up.
Comment #18
alexborsody commentedCool thanks for getting this done, it has a meta tag which is not specific to iOS
theme-color(which changes the mobile navbar color, a requirement for lighthouse) and is meant to be for any PWA related meta tags if any more come up.Comment #19
naveenvalecha@AlexBorsody,
It should remain in the pwa module. If there will be further meta tags for the Lighthouse, it should be moved to the pwa_lighthouse sub modul. What do you think?
Re: #13 and #15 Can you upload the default apple icon images which are referred to in the codebase?
Comment #20
alexborsody commentedThat sounds fine to me Naveen, do you suggest we just move
theme-colorback to where it was in pwa.module? If you want to reroll with this change I can test and we can get this initial work pushed. Maybe Paul can be so kind as to send those icons over, otherwise, I'll generate them.Comment #21
naveenvalechaWe should ship with the default icons in the modules and let the site builders override them if they want to.We'll document it in the Readme.txt of the module. "How to override the icons."
Comment #22
mrpauldriver commentedSorry Alex, I am not understanding you. Likewise @naveenvalecha with the Re: #13 and #15 comment
---
The definition of a PWA is evolving, and it arguably goes beyond the provision of a manifest file and a service worker. So I tend to think that anything that causes a Lighthouse PWA advisory should be part of the main module. This would include the apple-touch-icon, as well as theme-color.
In another post, @rupl recommended that a single apple-touch-icon of 192 pixels could be used. Existing functionality of the main module already addresses icon generation so this seems logical to me.
As for this module, yes it is currently about ios and metatags, but rather than tying it down, perhaps naming this submodule as pwa_extras would be more flexible.
---
Edit: Add link for @rupl comment about apple touch icon
Comment #23
naveenvalecha+1 I would rename the module in the next iteration of the patch if its also fine with the AlexBorsody
Comment #24
ruplI agree that for certain tags, putting them in the main module is the best course of action.
theme-colorand oneapple-touch-icon(or at least a very limited set) are indeed supplying critical functionality of this module IMO.If the list grows and grows, putting the extras in a submodule helps keep the output manageable by default, while catering to peoples' edge cases and desires in a more manageable way.
Comment #25
naveenvalechaI'll accommodate rest of #22 and #24 tomorrow as I'll need to go through the entire history of the conversion issue and the D7 version of the module. Here's the patch which renames the module name.
Comment #26
alexborsody commentedEverything you suggested sounds fine for me, thanks for getting involved naveenvalecha.
Comment #27
naveenvalechaHere's another iteration of the patch. It does the following:
Next:
- Add Readme.txt to the module
- Add hook_help to the module
- More clean up in pwa_extras_page_attachments
- Add apple-touch-icon of 192 pixels icon in the assets directory of the module and use it
- Test the module
Comment #28
alexborsody commentedUsing the simplytest.me link generated by Dreditor (anyone testing should definitely try this!), the module doesn't seem to be emitting any meta tags now...
PWA Extras Settings should also probably be under Progressive Web App dashboard link too. I can look more later.
Comment #29
alexborsody commentedComment #30
naveenvalechaI'll look at this tomorrow
Comment #31
alexborsody commentedHere is the meta tags submodule named as pwa_extras, remember to drop any needed icons for the tags into the root directory.
Next:
- Add Readme.txt to the module
- Add hook_help to the module
- More clean up in pwa_extras_page_attachments
- Add icons to the assets directory of the module and use it if none are found.
- Possibly add image upload functionality.
Comment #32
alexborsody commentedComment #33
alexborsody commentedNoticed some issues with this patch, needs more work not ready to test yet sorry.
Comment #34
alexborsody commentedThere was a typo in the previouse patch try this.
Comment #35
g.paluch commentedThanks for your contribution.
I reviewed the patch on clean Drupal install, and it works as intended.
Test:
After installing the module, I added tags and icons via admin page and all shows in the markup perfectly. I was able to uninstall it without problems.
The module admin page:
Generated markup:
Comment #37
alexborsody commentedComment #38
naveenvalechaThanks, Guys for taking this to end. I didn't get the time to take this up as my project is taking my whole day.
@AlexBorsody,
Any plans for a new release?
Comment #39
alexborsody commented