Skip to content

Return Empty arrays on latest version v3.2.4 #364

@Saqib92

Description

@Saqib92

On android 15 latest version return empty array.

this is my code:

import { Injectable } from '@angular/core';

declare var cordova: any;

@Injectable({
  providedIn: 'root'
})
export class HealthService {

  constructor() { }

  getData(startDate: any, endDate: any, type: string): Promise<any> {
    return new Promise((resolve, reject) => {
      try {
        let datatypes = {
          read: ['steps', 'calories', 'distance']
        };
        cordova.plugins.health.requestAuthorization(datatypes, (succ: any) => {
          if (succ) {
            let opt = {
              startDate: new Date(startDate),
              endDate: new Date(),
              dataType: type.toLowerCase(),
              limit: 5000
            };
            cordova.plugins.health.query(opt, (data: any) => {
              console.log(data) // empty array []
              resolve(data);
            }, (err: any) => {
              console.log(err)
              reject(err);
            });
          }
        }, (err2: any) => {
          reject(err2);
        });
      } catch (e: any) {
        console.log(e)
      }
    });
  }
}

Surprisingly, old version v2.1.0 is working fine on android 15 but showing app blocked popup on android < 15.

In new version:
queryAggregated()
is returning data only for calories no data for steps and distance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions