Push-API still not supported in Safari 16 (Technology Preview)? - safari

We want to test if our implementation of web-push notifications will run in Safari 16 as well. So we downloaded the "Safari Technology Preview" 148 from https://developer.apple.com/safari/resources/ to test our implementation of Web-Pushs on macOS Monterey 12.4.
We use this code to detect if a browser supports Web-Pushes:
function WebPushSupported()
{ if (!window.Notification)
{ return false;
}
if (!('serviceWorker' in navigator))
{ return false;
}
if (!('PushManager' in window))
{ return false;
}
return true;
}
This works fine in Chrome, Firefox and so on, but Safari 16 has no object "PushManager" in window.
Are WebPushes through the Push-API still not supported in Safari 16?

Related

Running tests with flags from chrome cypress

I have some test cases that use webcam and our test enviroment needs for using webcam to have set flag in chrome --unsafely-treat-insecure-origin-as-secure
How can I for some test sets have this set in chrome with cypress?
Thanks
You can pass flags to the chrome browser in Cypress by writing a Cypress plugin as seen in the official documentation here: https://docs.cypress.io/api/plugins/browser-launch-api.html#Usage.
Navigate to your cypress/plugins directory and add the following code
module.exports = (on, config) => {
on('before:browser:launch', (browser = {}, launchOptions) => {
// `args` is an array of all the arguments that will
// be passed to browsers when it launches
if (browser.name === 'chrome') {
launchOptions.args.push('--unsafely-treat-insecure-origin-as-secure');
}
// whatever you return here becomes the launchOptions
return launchOptions;
});
};

Issue with WebRTC/getUserMedia in iOS 14 Safari and phone sleep/unlock

I seem to have noticed a regression with getUserMedia in iOS 14 Safari. Here are steps to reproduce:
Go to https://webrtc.github.io/samples/src/content/getusermedia/gum/ on iOS 14 Safari
Click "Open camera" and accept camera permissions; you should see local camera video.
Click the power button and lock the phone; let the phone go to sleep
Unlock/wake the phone; the local camera video is gone.
This does not happen on devices running iOS 13.
My questions are:
Can anyone else confirm this on their devices? I have only tested on iPhone 11 so far.
Has anyone found a solution yet?
Yes, I am having the a similar strange issue with iOS 14.2 and getUserMedia I can only get
navigator.mediaDevices.getUserMedia({video: true }) to work
If I change it to:
navigator.mediaDevices.getUserMedia({ audio: true, video: true })
it will fail.
It's not an issue with code as I tested my project on safari MacOS, chrome for MacOS, linux Firefox.
As a temp fix so I could move on with my life for the moment I did this:
const constraints = navigator.userAgent.includes("iPhone") ? {video:true} : {
audio:true,
video: {
width: { ideal: 640 },
height: {ideal: 400 }
}
};
Yes also here!
I check this behavior in Browserstack with iOS:
12.x: ✓
13.x: ✓
14.x: ✗
Try this:
navigator.mediaDevices.getUserMedia({ audio: true, video: true })
.then(stream => {
const videoTracks = stream.getVideoTracks();
console.log(videoTracks[0].enabled);
document.querySelector('video').srcObject = stream;
});
// Output
true <-- ?
Then if you try again get the camera, but replacing the video track on the previous MediaStream works.
Sometimes if you use video constraints with facingMode: 'user' also works, why? I don't know.
I still can't find a consistent solution.
Having the same issue on iPad pro 2nd generation with iOS 14.7.1 and iPhone 7 iOS 14.6.x. The only solution I found that seems to constantly work is to call getUserMedia separated by audio and video constraints. As an example:
async function getMedia(constraints) {
let videoStream = null;
let audioStream = null;
try {
videoStream = await navigator.mediaDevices.getUserMedia({video: true});
audioStream = await navigator.mediaDevices.getUserMedia({audio: true});
/* use the stream */
} catch (err) {
/* handle the error */
}
}
You can replace {video: true} or {audio: true} with your desired constraints. Then you can either work with the separate MediaStream objects or to construct your own MediaStream object from the audio and video tracks of your streams.

Expo BackgroundFetch not working on android when app is terminated

The task gets registered it also works.When in recent apps it works.When gets deleted it stops working!
Expo CLI 3.11.3 environment info:
System:
OS: Windows 10
Binaries:
Yarn: 1.21.0 - C:\Users\Steve\AppData\Roaming\npm\yarn.CMD
npm: 6.9.0 - E:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 3.5.0.0 AI-191.8026.42.35.5900203
SDK version : 36.0.0
Standalone app on android 7
Just to confirm I was right I went into my apps background in my setting in my phone,I can see the app is in background progress.As soon as I remove it from recent apps it gets gone from the background progress too.So everything is as I described and no doubts about it.I also have used:
stopOnTerminate: false,
But it doesn’t do anything.
Here’s a function that does register the tasks and everything:
import * as BackgroundFetch from 'expo-background-fetch';
import * as TaskManager from 'expo-task-manager';
export async function registerFetchTask(taskName, jobCallback, interval) {
TaskManager.defineTask(taskName, jobCallback);
const status = await BackgroundFetch.getStatusAsync();
switch (status) {
case BackgroundFetch.Status.Restricted:
case BackgroundFetch.Status.Denied:
console.log("Background execution is disabled");
return;
default: {
console.log("Background execution allowed");
let tasks = await TaskManager.getRegisteredTasksAsync();
if (tasks.find(f => f.taskName === taskName) == null) {
console.log("Registering task");
await BackgroundFetch.registerTaskAsync(taskName,{
minimumInterval: 60,
stopOnTerminate: false,
startOnBoot: true,
});
tasks = await TaskManager.getRegisteredTasksAsync();
console.log("Registered tasks", tasks);
} else {
console.log(`Task ${taskName} already registered, skipping`);
}
console.log("Setting interval to", interval);
await BackgroundFetch.setMinimumIntervalAsync(interval);
}
}
}
Inside app.js I call:
registerFetchTask('wow',()=>{
fetchServer('/test',{});
console.log('WOWWW HIIIIIIIII YGNNNNNN');
},5);
The fetchServer will add things to my database on my laptop.So I can see if the app is running the task I’m getting new rows in the database.

Ionic 3 / AngularFire2 authState not persisting on Android (but works on Web)

Hey all so this is kind of driving me crazy.
Here is the code:
constructor(
platform: Platform,
statusBar: StatusBar,
splashScreen: SplashScreen,
afAuth: AngularFireAuth
) {
afAuth.authState.subscribe(user => {
if (user) {
this.rootPage = "TabsPage";
console.log("logging in");
console.log(JSON.stringify(user)); // user
} else {
this.rootPage = "LoginPage";
console.log("logging out");
console.log(JSON.stringify(user)); // null
}
});
When run on the web I can login to my app and then log out as expected. However on Android (testing via ionic cordova run android) the user subscription is set and then immediately set to null.
So I figured it out!
It was the version of firebase that I was using v4.12.1
I changed to version 4.11.0 and the problem stopped occuring.

In Nightwatch, `.url()` blocks assertions for too long

It appears that using browser.url() (http://nightwatchjs.org/api/#url) to navigate causes the WebDriver client to wait until the page is fully loaded - however I have assertions I want to make before that point.
"Shows splash screen for a few seconds": function(client) {
client
.url(client.testURL)
// at this point, the splash has already come and gone, so
// this next command times out
.waitForElementVisible('#splash img', 10000)
.waitForElementNotVisible('#splash', 10000);
},
Is this possible? I think my only other option is to disable the splash in a test scenario.
I'm running these tests on Firefox v45.
You can do this by setting Firefox profile preferences as shown in below
https://github.com/nightwatchjs/nightwatch/issues/748
The preference you need to set is webdriver.load.strategy to be unstable. But this means that waiting for page to load is now all your business
var FirefoxProfile = require('firefox-profile');
function setProfile(browser, profile, callback) {
profile.encoded(function (encodedProfile) {
browser.options.desiredCapabilities['firefox_profile'] = encodedProfile;
callback();
});
}
function setFirefoxProfile(browser, done) {
var profile = new FirefoxProfile();
profile.setPreference('webdriver.load.strategy', 'unstable');
setProfile(browser, profile, done);
}
// and in my test module
before: function (browser, done) {
setFirefoxProfile(browser, done);
}