MSakamaki / ngx-onesignal

Anguler 7+ oneSingal service
https://nicedoc.io/MSakamaki/ngx-onesignal
MIT License
15 stars 9 forks source link

Support for Safari #48

Open nncl opened 4 years ago

nncl commented 4 years ago

I am submitting a

What is the expected behavior?

Be able to get the user id through await OneSignal.getUserId()

What is the current behavior?

It returns a bug when subscribing as shown:

Screen Shot 2020-10-31 at 4 38 19 PM Screen Shot 2020-10-31 at 4 37 57 PM

What are the steps to reproduce?

As far as I can see just creating the project as the example in the docs.

What is the use-case or motivation for changing an existing behavior?

Which versions are you using for the following packages?

Angular: 10.2.0 Angular CDK: 10.2.6 Angular CLI: 10.2.0 Nx (option): ngx-onesignal: 10.0.0

Is there anything else we should know?

This is my app.module:

NgxOneSignalModule.forRoot({
      appId: 'my-app-id,
      autoRegister: false,
      allowLocalhostAsSecureOrigin: true,
      notifyButton: {
        enable: true,
      },
    }),

And my app.component:

import { Component, OnInit } from '@angular/core';
import { OneSignalService } from 'ngx-onesignal';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {

  constructor(public readonly onesignal: OneSignalService) {
    (window as any).ngxOnesignal = this.onesignal;
  }

  ngOnInit(): void {
    setTimeout(() => {
      this.onesignal.subscribe();
      console.log(`Initiated`);
    }, 2000);
  }
}

Also, I couldn't see anything about the safari_web_id property as described in https://documentation.onesignal.com/docs/safari-web-push-setup, so, does this wrapper supports it?

My Safari version is 14.0 (15610.1.28.1.9, 15610) and I'm on a Mac OS Catalina 10.15.7.

You can access my example here https://onesignal-testing.surge.sh and also its repository on Github https://github.com/nncl/ngx-onesignal-test

I really appreciate your help :)

MSakamaki commented 4 years ago

@nncl Yes, I support safari_safari_web_id in safari.

I have been suffering from the same phenomenon since the day before yesterday, but now it seems to be able to call the API successfully. Are still experiencing the problem in your environment? If the problem is still there, I'll find a reproducible environment and look deeper into it.

nncl commented 4 years ago

@MSakamaki yes, unfortunately still happening when testing on Safari this following environment https://onesignal-testing.surge.sh/ Have you tried? If so, this error is shown for you?

Thanks for your time.

MSakamaki commented 3 years ago

Temporary Report

After investigating, I found that there is a problem with the Driver inside ngsw-worker.js.

It appears that the server is returning a CORS error due to the server hooking up the "https://onesignal.com/" communication when fetching onesignal communications and executing from the application's domain. We have been able to confirm that it can be worked around by temporarily disabling this feature, but we are still investigating the underlying solution.

https://github.com/angular/angular/blob/master/packages/service-worker/worker/src/driver.ts#L404

nncl commented 3 years ago

@MSakamaki thanks, I appreciate your time. I'll try to disable and test as you did, and also if I come up with something else I'll let you know.