Add to home screen push notification deep linking opens home page of web app instead of link location in web app
Reported by
ja...@onesignal.com,
Jul 28 2016
|
||||||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.82 Safari/537.36 Example URL: Steps to reproduce the problem: 1. Visit https://notify.tech, and subscribe to web push notifications. You should get a web push notification thanking you for subscribing (you can just swipe this away). Make sure you're not using Chrome in Incognito mode, since Incognito mode doesn't support push notifications. 2. Open the Developer Tools Console (make sure the frame context is "top"), and run in the console: OneSignal.sendSelfNotification('OneSignal Test Notification', 'Test add to homescreen deep linking.', 'https://notify.tech/2016/03/30/test-scheduled-featured-post-image/') 3. Click on the "OneSignal Test Notification" notification, and observe it correctly opening the URL "https://notify.tech/2016/03/30/test-scheduled-featured-post-image/". (Note: You can repeat steps 2 - 3 again if you'd like with a different valid URL like https://notify.tech/2016/06/06/test-post-no-send/) 4. Wait 5 minutes. 5. Open a new tab to https://notify.tech, and accept the prompt to "Add to homescreen". BUG #1: 6. Follow the same procedure described in step #2 to send yourself a notification. Observe that the URL opened is https://notify.tech and *not* the specific URL our notification is supposed to open. Chrome 51, Android 4.2: My experience was the web app does not need to be opened at least once in order for the URL to open in the web app. The web app immediately opened. I could just be confusing this part and maybe I already opened the web app. Chrome 51, Android 6.0.1: My experience was the web app does need to be opened at least once, in order for the URL to open in the web app. My experience was that the URL opened in the normal Chrome browser (outside the web app), *but the URL was still incorrect* (only the home page of https://notify.tech was opened, and not https://notify.tech/2016/03/30/test-scheduled-featured-post-image/). Not sure if OS version is related at all, maybe I remembered things wonky here. BUG #2 : 7. 7.1. Remove the added home screen icon from your home screen. 7.2 Tap the green lock icon next to the URL to Clear site data and reset permissions. Close all tabs, open a new tab to https://notify.tech and Clear site data again just in case. 7.3 Open https://notify.tech again, and subscribe to notifications. 7.4 Send yourself the same notification described in step #2, and observe that, on Chrome 52, *the web app is still opened* for this notification. What is the expected behavior? BUG #1 (the main bug this thread was opened for): I expected the web app to be opened directly to the link location. Instead the web app was opened to the home page (maybe the manifest's start_url?). BUG #2 : If the icon is removed from the home screen, and site data is cleared, the web app should not be opening when clicking another notification. What went wrong? See expected behavior. Does it occur on multiple sites: N/A Is it a problem with a plugin? N/A Did this work before? N/A Does this work in other browsers? N/A Chrome version: 52.0.2743.82 Channel: stable OS Version: OS X 10.11.4 Flash Version: Shockwave Flash 22.0 r0 Tested on Chrome 51.0.2704.81 on Android 4.2, and Chrome 51.0.2704.81 (same browser version) on Android 6.0.1.
,
Aug 4 2016
Retagging this as OS=Android, not OS=Mac.
,
Aug 8 2016
,
Aug 8 2016
Punting to dominick and pkotwicz who have been editing these files.
,
Aug 9 2016
Jason, thanks for sending this in. :) Regarding bug #1, this is a duplicate of crbug.com/632462 which I fixed a few weeks ago and should be in Chrome 52 (as you note). Regarding bug #2 , this is due to one unfortunate limitation and an actual bug. The unfortunate limitation is that Android provides no way for us to know if a shortcut is or isn't still on the home screen. So we use a 10 day launch heuristic; if the site was launched from homescreen within the last 10 days, we assume it's still there and permit notification deep linking. The bug is that the "clear site data" button actually doesn't clear the fact that the website was recently visited (this will be cleared if you use the overflow menu -> Settings -> Clear Browsing Data). I'll fix this so that the time is also cleared via the clear site data button.
,
Aug 9 2016
Hey dominickn, Thanks for the quick reply! It does look like this issue was fixed in Chrome 52 (awesome!). I did notice something else though (is this a bug / if so, should I open another issue for it?) If the web app is not open, a notification that deep links to the web app does so successfully in Chrome 52 (opens the web app to the correct page). However I noticed if the web app is already open to page A, and a notification deep links to page B, the web app does not navigate to page B; instead, the web app remains on page A. This behavior occurs both when the web app is a foreground task and background task. This behavior does not occur if the web app is killed, because then the notification deep links correctly.
,
Aug 9 2016
#6: this may be due to the way in which you're opening the notification. If you focus a window with client.focus() in your service worker, this will simply bring the existing window back to the front without navigating it to the URL (focus() doesn't do any navigation). To avoid this, you can either remove the .focus() call, or guard it with a conditional with checks that the url open in the client matches the url that you want to open. Does that make sense? If you still find that there's any issue after checking that out, open a new bug with the Javascript code in your service worker and I'll take a look.
,
Aug 9 2016
Thanks Dominick! That makes sense, we are calling client.focus().
,
Jan 9 2017
>However I noticed if the web app is already open to page A, and a notification deep links to page B, the web app does not navigate to page B; instead, the web app remains on page A. This behavior occurs both when the web app is a foreground task and background task. This behavior does not occur if the web app is killed, because then the notification deep links correctly. I've noticed this on Chrome 55 too. The way I'm opening the url is: `event.waitUntil(clients.openWindow(urlToOpen));`
,
Jan 15 2018
I think our improved add to home screen fixes these deep linking issues since web apps are now proper Android APKs. Please re-open if you see more issues, thanks!
,
Jan 15 2018
|
||||||
►
Sign in to add a comment |
||||||
Comment 1 by ja...@onesignal.com
, Jul 28 2016