About ionic3 Aurora push Registration ID cannot be obtained for the first time

Keywords: iOS angular github xcode

Question:

1. The Registration ID cannot be obtained for the first time. You can use setTimeout to delay obtaining.
2. For Registration ID, the first time you open the app, you cannot get the id until you exit the app. Because the login user needs to be associated, the id must be sent to the background after login.

Edition:

  • lonic3
  • angular cli: 6.0.7
  • node: 8.11.1

About how to download jpush plug-ins and Aurora push documents:

Specific code:

  • Initialize jpush first
    • app.component.ts
jpush.init();
jpush.setDebugMode(false);
  • Send id after getting token in login interface
    • login.ts
public doLogin = () => {

      this.ajax.loadData({
        uri: 'login',
        method: 'post',
        title: 'Login request',
        data: this.loginForm.value,
        //afterFn: afterFn
      }).subscribe(res => {
        this.msg.hideLoader();
        if (res.status === 1) {
          const crypt_token: string = res.payload.crypt_token;
          const zhiwei: string = res.payload.zhiwei;
          this.storage.set('zhiwei', zhiwei);
          this.storage.set('crypt_token', this.stringCode.encode(crypt_token)).then(() => {
            this.events.publish('login', res);
            this.viewCtrl.dismiss();

            //Obtain token After, get Aurora push id,Then send id
            setTimeout(() => {
              this.jpush.getRegistrationID().then(res => {
                this.registrationID = res;
                // alert('login Time acquisition id:'+this.registrationID);

                this.getJiGuangID(this.registrationID);
              });
            }, 1000);
          });
        }
      });
    }
  }


  /**
   * @description Transmitting Auroraid
   * @private
   * @memberof LoginPage
   */
  public getJiGuangID = (id) => {
    this.ajax.loadData({
      uri: `jiguang_info/` + id,
      method: 'get',
      title: 'Send Aurora push registrationID '
    }).subscribe(res => {
      // alert('login Time send id Success.')
    })
  }

Problems still exist:

  • ios development environment can receive notification messages, and production mode can't receive notification messages.
  • ios is published to the app store, and the next app still can't get the id. Use xcode to connect to the iPhone's installed app to get the id.

If you know the above problems, please leave a message to tell us the solution or add QQ: 987069913, thank you very much.

Posted by djmc48 on Sun, 05 Jan 2020 14:14:25 -0800