[Device Only] Running Ionic v3 on devices result in an "TypeError: Cannot Read Property 'some' of null"

I nearly finished my Ionic App Development and it works perfectly fine on my Android Emulator (Pixel 2 XL, Android API 27). But When I deploy it to my phone, it results in several problems.

  1. There should be a parent-child relationship in my dishdetail and menu page - when clicking on the picture on menu page, the user will be redirected to the dishdetail page. But this “click-redirect” action doesn’t work on my device.

  2. There is also an option that the user is able to add a specific dish into the favorite list. Then the favorite list is stored externally in the device. However, when I open the favorites page, a “TypeError: Cannot Read Property ‘some’ of null” occurs and no data is loaded.

I suspect that the problem may lie in that the app is not able to get the storage on the device, so I deploy android-permissions to aid me with this. But it still doesn’t seem to work.

Below is my favorite.ts provider (the problem can only in the “this.favorites.some” part, right?).

export class FavoriteProvider {

  favorites: Array<any>;

  constructor(public http: Http, private dishservice: DishProvider, private storage: Storage,
    private localNotifications: LocalNotifications) {
    console.log('Hello FavoriteProvider Provider');
    this.favorites = [];
    this.storage.get('favorites').then( favor => this.favorites = favor );

  addFavorite(id: number): boolean {
    if (!this.isFavorite(id))
    console.log('favorites', this.favorites);
    this.storage.set('favorites', this.favorites);
      id: id,
      text: 'Dish ' + id + ' added as a favorite successfully',
    return true;

  isFavorite(id: number): boolean {
    return this.favorites.some(el => el === id);

  getFavorites(): Observable<Dish[]> {
    return this.dishservice.getDishes()
      .map(dishes => dishes.filter(dish => this.favorites.some(el => el === dish.id)));

  deleteFavorite(id: number): Observable<Dish[]> {
    let index = this.favorites.indexOf(id);
    if (index >= 0) {
      this.favorites.splice(index, 1);
      this.storage.set('favorites', this.favorites);
      return this.getFavorites();
    else {
      console.log('Deleting non-existant favorite', id);
      return Observable.throw('Deleting non-existant favorite' + id);


ionic (Ionic CLI) : 4.10.2 (C:\Users<Username>\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.2


cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 7.1.4
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.1.2, (and 11 other plugins)


NodeJS : v10.14.1 (C:\Program Files\nodejs\node.exe)
npm : 6.4.1
OS : Windows 10

Please let me know if you need any further information.