Quantcast
Channel: Ionic Forum - Latest topics
Viewing all 70913 articles
Browse latest View live

(Ionic 5) Override ion-back-button logic to show confirm message before leaving a page

$
0
0

Hi guys! Is there an easy way to prevent page popping when pressing ion back button? I’d like to show a confirmation dialog to user before leaving page. I’m using Ionic 5.2.2 and trying this, but not working:

component.html
<ion-back-button *ngIf=“canGoBack” (click)=“this.backButtonClicked($event)”>

component.ts
public backButtonClicked(event) {

event.preventDefault();

event.stopPropagation();

event.stopImmediatePropagation(); 

}

1 post - 1 participant

Read full topic


Logout Ionic

$
0
0

Hello, what is the best way to logout?
I remove items from the localstorage, clean and navigate to the login, but when I log in again it does not work, I must use the back button and return to make it work. Any solution? Thank you…

1 post - 1 participant

Read full topic

Command failed with exit code 65 - Cordova-ios 6.1.0 and Angular 9

$
0
0

Hi there,

I am getting a compilation error on cordova-ios 6.1.0 and Angular 9. XCode 11.5. The latest stack.
Not sure what is really happening, I really appreciate any tips on how to fix that:

CompileStoryboard Sample/CDVLaunchScreen.storyboard
    cd /Users/mm/Documents/dev/Sample.PGK/Core/Sample.PGK.Core.Ionic/platforms/ios
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/mm/Documents/dev/Sample.PGK/Core/Sample.PGK.Core.Ionic/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:/Users/mm/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands"
    export XCODE_DEVELOPER_USR_PATH=/Applications/Xcode.app/Contents/Developer/usr/bin/..
    /Applications/Xcode.app/Contents/Developer/usr/bin/ibtool --errors --warnings --notices --module Sample --output-partial-info-plist /Users/mm/Library/Developer/Xcode/DerivedData/Sample-bvrieshnghaqwbegvatmqkxrcaky/Build/Intermediates.noindex/Sample.build/Debug-iphonesimulator/Sample.build/CDVLaunchScreen-SBPartialInfo.plist --auto-activate-custom-fonts --target-device iphone --minimum-deployment-target 10.0 --output-format human-readable-text --compilation-directory /Users/mm/Library/Developer/Xcode/DerivedData/Sample-bvrieshnghaqwbegvatmqkxrcaky/Build/Intermediates.noindex/Sample.build/Debug-iphonesimulator/Sample.build /Users/mm/Documents/dev/Sample.PGK/Core/Sample.PGK.Core.Ionic/platforms/ios/Sample/CDVLaunchScreen.storyboard
/* com.apple.ibtool.document.errors */
/Users/mm/Documents/dev/Sample.PGK/Core/Sample.PGK.Core.Ionic/platforms/ios/Sample/CDVLaunchScreen.storyboard:Ze5-6b-2t3: error: Named colors do not work prior to iOS 11.0.

CompileAssetCatalog build/emulator/Sample.app Sample/Images.xcassets
    cd /Users/mm/Documents/dev/Sample.PGK/Core/Sample.PGK.Core.Ionic/platforms/ios
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/mm/Documents/dev/Sample.PGK/Core/Sample.PGK.Core.Ionic/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:/Users/mm/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands"
    /Applications/Xcode.app/Contents/Developer/usr/bin/actool --output-format human-readable-text --notices --warnings --export-dependency-info /Users/mm/Library/Developer/Xcode/DerivedData/Sample-bvrieshnghaqwbegvatmqkxrcaky/Build/Intermediates.noindex/Sample.build/Debug-iphonesimulator/Sample.build/assetcatalog_dependencies --output-partial-info-plist /Users/mm/Library/Developer/Xcode/DerivedData/Sample-bvrieshnghaqwbegvatmqkxrcaky/Build/Intermediates.noindex/Sample.build/Debug-iphonesimulator/Sample.build/assetcatalog_generated_info.plist --app-icon AppIcon --compress-pngs --enable-on-demand-resources YES --filter-for-device-model iPhone12,8 --filter-for-device-os-version 13.5 --sticker-pack-identifier-prefix nz.co.Sample.app.sticker-pack. --development-region en --target-device iphone --minimum-deployment-target 10.0 --platform iphonesimulator --product-type com.apple.product-type.application --compile /Users/mm/Documents/dev/Sample.PGK/Core/Sample.PGK.Core.Ionic/platforms/ios/build/emulator/Sample.app /Users/mm/Documents/dev/Sample.PGK/Core/Sample.PGK.Core.Ionic/platforms/ios/Sample/Images.xcassets
2020-06-26 13:09:04.566 ibtoold[63485:1359377] DEBUG: Added to environment: {
    TMPDIR = "/var/folders/ls/8k4nss195yvd32fycs37f2_40000gp/T/77A96612-43CD-4CEA-80DE-3AEAA615D81E";
}

** BUILD FAILED **


The following build commands failed:
	CompileStoryboard Sample/CDVLaunchScreen.storyboard
(1 failure)
Command finished with error code 65: xcodebuild -workspace,Sample.xcworkspace,-scheme,Sample,-configuration,Debug,-sdk,iphonesimulator,-destination,platform=iOS Simulator,name=iPhone SE (2nd generation),build,CONFIGURATION_BUILD_DIR=/Users/mm/Documents/dev/Sample.PGK/Core/Sample.PGK.Core.Ionic/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/mm/Documents/dev/Sample.PGK/Core/Sample.PGK.Core.Ionic/platforms/ios/build/sharedpch
xcodebuild: Command failed with exit code 65
Error: xcodebuild: Command failed with exit code 65
    at ChildProcess.whenDone (/Users/mm/Documents/dev/Sample.PGK/Core/Sample.PGK.Core.Ionic/platforms/ios/cordova/node_modules/cordova-common/src/superspawn.js:136:25)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:962:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
[ERROR] An error occurred while running subprocess cordova.
        
        cordova build ios --verbose exited with exit code 65.
        
        Re-running this command with the --verbose flag may provide more information.
  ionic:utils-process onBeforeExit handler: 'process.exit' received +0ms
  ionic:utils-process onBeforeExit handler: running 2 functions +1ms
  ionic:utils-process processExit: exiting (exit code: 65) +79ms

I have tried this fix approach, but it didn’t work in my case.
From the error details, it seems that cordova is building on a version prior to IOS 11.
Is there a way to force the compilation process to use iOS 11?

My system details:

Ionic:

   Ionic CLI                     : 6.10.0 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.2.1
   @angular-devkit/build-angular : 0.901.7
   @angular-devkit/schematics    : 9.1.7
   @angular/cli                  : 9.1.7
   @ionic/angular-toolkit        : 2.2.0

Cordova:

   Cordova CLI       : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms : ios 6.1.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 5.0.0, (and 34 other plugins)

Utility:

   cordova-res                          : not installed
   native-run (update available: 1.0.0) : 0.2.2

System:

   ios-deploy : 1.9.2
   ios-sim    : 8.0.2
   NodeJS     : v10.15.0 (/usr/local/bin/node)
   npm        : 6.9.0
   OS         : macOS Catalina
   Xcode      : Xcode 11.5 Build version 11E608c

I really appreciate any help on this.

1 post - 1 participant

Read full topic

Tabs hang issue

$
0
0

hi can anyone know why my app is hanging when i switch tabs between fast it is hanging
i am using ionic 4 and angular 8 and i have attach gif file you can check and let me know the solution

1 post - 1 participant

Read full topic

Make it impossible to go to the previous one

$
0
0

So, I have a Login Page and a Home Page. Once I do the login and I’m directed to the Home Page I want to make it impossible for the user to go to the Login Page (when I click on the default previous button of the phone, it goes back to Login Page).

What is the best way to do this?

TIA

1 post - 1 participant

Read full topic

Upload images and videos when app is closed

$
0
0

In our app we give the option to upload loads of images and photos at the same time. The problem is, when the app is closed the uploads fail of course. So my question is, can I make a background task so the images/videos are uploaded even when the app is closed. Or can I do it like facebook, where the image seems to be uploaded in a notification +track the progress in that push notification.

Any tips/explanations are welcome. New to any kind of background tasks so all help/explanations are welcome. We’re here to learn after all.

1 post - 1 participant

Read full topic

Compress captured image with camera, using Capacitor

$
0
0

Hello how are you?
I wanted more information, I already read the official documentation
The images taken by devices, what size and weight does it have?
Can you compress or handle this?

Kind Regards

Federico Ciampi

1 post - 1 participant

Read full topic

How to debug Ionic5/Capacitor app on Android devices?

$
0
0

Hi,
I used to debug Ionic/Cordova apps on a device using the command:
ionic cordova run android -l

So that each modification was loaded in real-time.

How can I debug an Ionic/Capacitor app in a similar way?
Do I have to run each time these commands?

ionic build
npx cap sync android
npx cap open android

Thank you very much

cld

1 post - 1 participant

Read full topic


App is showing an "android design" in ios device

$
0
0

Captura de pantalla 2020-06-26 a la(s) 10.02.18

(First of all, sorry for my bad english, lol)

Y run my app in the browser in a ios responsive form, but as can you see, the app is “taking” an android design, instead an ios design. When i reload the page, the app take the correct design.

Captura de pantalla 2020-06-26 a la(s) 10.02.31

How can i resolve this issue?

1 post - 1 participant

Read full topic

Error Firebase API Key no valida

$
0
0
W/Firebase-Installations: Error when communicating with the Firebase Installations server API. HTTP response: [400 Bad Request: {
      "error": {
        "code": 400,
        "message": "API key not valid. Please pass a valid API key.",
        "status": "INVALID_ARGUMENT",
        "details": [
          {
            "@type": "type.googleapis.com/google.rpc.Help",
            "links": [
              {
                "description": "Google developers console",
                "url": "https://console.developers.google.com"
              }
            ]
          }
        ]
      }
    }
    ]
E/Firebase-Installations: Firebase Installations can not communicate with Firebase server APIs due to invalid configuration. Please update your Firebase initialization process and set valid Firebase options (API key, Project ID, Application ID) when initializing Firebase
java.lang.IllegalArgumentException: Please set a valid API key. A Firebase API key is required to communicate with Firebase server APIs: It authenticates your project with Google.

Estos son los errores que me aparecen en el log de android studio, cuando inicio la App crashea al instante.
Al probarlo con ionic lab no da ningún error y me funciona perfectamente el login por firebase.

Tengo puesto el firebaseConfig sacado de el proyecto web en Firebase tanto en environment.ts como en environment.prod.ts y llamado en el app.module.ts.

export const firebaseConfig = {
  apiKey: "AIzaSyAzbwyFM_XIIzhlvg9O5EHTOXDSqfpZ53A",
  authDomain: "homelist-42d67.firebaseapp.com",
  databaseURL: "https://homelist-42d67.firebaseio.com",
  projectId: "homelist-42d67",
  storageBucket: "homelist-42d67.appspot.com",
  messagingSenderId: "660380788284",
  appId: "1:660380788284:web:d5ffad28c0caa081398539",
  measurementId: "G-G329JP79PC"
  };

app.module.ts

import { AngularFireModule } from "@angular/fire";
import { firebaseConfig } from './../environments/environment';

@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [
    BrowserModule,
    IonicModule.forRoot(),
    AppRoutingModule,
    HttpClientModule,
    BrowserAnimationsModule,
    MatIconModule,
    HeaderModule,
    FormsModule,
    ReactiveFormsModule,
    SuperTabsModule.forRoot(),
    AngularFireModule.initializeApp(firebaseConfig),
    AngularFirestoreModule.enablePersistence(),
    AngularFireAuthModule
    ],
    exports:[
      HeaderModule,
      MatIconModule
    ],
  providers: [
    StatusBar,
    SplashScreen,
    AdMobFree,
    ApiService,
    FirestoneService,
    GooglePlus,
    { provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
    BarcodeScanner,
    Camera
  ],
  bootstrap: [AppComponent]
})

Después tengo el google-service.json descargado desde el proyecto de Android en Firebase, está copiado tanto en la ruta del proyecto como en la ruta plataforms/android

{
    "project_info": {
        "project_number": "660380788284",
        "firebase_url": "https://homelist-42d67.firebaseio.com",
        "project_id": "homelist-42d67",
        "storage_bucket": "homelist-42d67.appspot.com"
    },
    "client": [{
        "client_info": {
            "mobilesdk_app_id": "1:660380788284:android:3238909d1054cddb398539",
            "android_client_info": {
                "package_name": "com.homelist"
            }
        },
        "oauth_client": [{
                "client_id": "660380788284-bp3tn0v9fi1j57a3p5nigqp980dhctie.apps.googleusercontent.com",
                "client_type": 1,
                "android_info": {
                    "package_name": "com.homelist",
                    "certificate_hash": "411b8bb5494cb617a4b04f6f612d202049d1c083"
                }
            },
            {
                "client_id": "660380788284-6itgp7d0pnfc6fgcg3cfp4e94o3qj013.apps.googleusercontent.com",
                "client_type": 3
            }
        ],
        "api_key": [{
            "current_key": "AIzaSyDRJmIAm2ZGeS70qPeJdUoq_BwahQalTkT"
        }],
        "services": {
            "appinvite_service": {
                "other_platform_oauth_client": [{
                        "client_id": "660380788284-6itgp7d0pnfc6fgcg3cfp4e94o3qj013.apps.googleusercontent.com",
                        "client_type": 3
                    },
                    {
                        "client_id": "660380788284-jlfcd74h2arcvv37lnb4j1eri3p2k8ph.apps.googleusercontent.com",
                        "client_type": 2,
                        "ios_info": {
                            "bundle_id": "com.homelist"
                        }
                    }
                ]
            }
        }
    }],
    "configuration_version": "1"
}

También he leído que puede ser necesario que se incluya en el config.xml

<platform name="android">
        <resource-file src="google-services.json" target="app\google-services.json" />

No he encontrado ninguna solución valida.

1 post - 1 participant

Read full topic

Social network starter

$
0
0

Hey guys, I just created a social network starter.

Main features

  • Lazy-loading
  • Auth pages (login, register, forgot and reset)
  • Themes (default and dark)
  • Ngrx
  • LocalStorage
  • i18n (English and Russian)
  • Responsive design
  • Music player (on bottom - swipeable)

Everybody welcome and especially contributors! Let’s work together. :boom:

DEMO GIF

1 post - 1 participant

Read full topic

Structure of view.ts - split view into multiple controllers

$
0
0

I am wondering whether I can split the MVC model of an ionic view into multiple controllers for one view? My main view seems so feature laden that the view.ts becomes extremely long. Manageable, but annoying. I’m considering to create some parts a component, but wondering if I could instead delegate items into “child” controllers to keep the main view.ts readable.

Is this possible? I can not find any real examples.

Thanks

ps: I’m on Ionic5

1 post - 1 participant

Read full topic

Ion toogle and ion radio doesn't work in a menu

$
0
0

Hi i have to put one toggle item and N radio items in a menu, both items are displayed correctly but i can’t interact with these, when i select toggle or radio nothing happens, no viusal changes happens and the events are not raised.
Another thing: If i put toggle or radio in ion-content, ion-header, footer (outside of menu) it works perfectly.

Here is my code:

HTML


<ion-menu side="end" menuId="first" contentId="main" class="menu-side-item">

  <ion-header>
    <ion-toolbar color="tertiary">
      <ion-title>Configuración</ion-title>
    </ion-toolbar>
  </ion-header>
  <ion-content>

    <ion-list>

      <!-- I have tried with "enabled" and without "enabled" is the same-->
      <ion-item>Notificaciones<ion-toggle enabled (ionChange)="notifyChange($event)"></ion-toggle>
      </ion-item>

      <ion-item>Credenciales</ion-item>

      <ion-radio-group (ionChange)="changedCompany($event)">

        <ion-item *ngFor="let data of dataUser.companies">
          <img src="{{data.logo}}" alt="company logo" class="logo-item">{{data.name}}
          <ion-radio value="{{data.name}}" >
          </ion-radio>
        </ion-item>

      </ion-radio-group>
...

TS


  notifyChange(event) {
 
      this.notifyEnabled = event.detail.checked;
      console.log(this.notifyEnabled); 

  }

changedCompany(event){
  console.log(event.target.value);
 
}

And this is how the items are displayed
pp

Can you help me please? what am i doing wrong?

Regards

1 post - 1 participant

Read full topic

Comments form / send email

$
0
0

hey,

I would like to create a comments form (in my Ionic React app) that when submitting sends to a specific mailbox. I dont’ want to use email composer as that seems to open the on phone email client to achieve this, I want to stay in the app. Can I use something like formspree to achieve this or is there a better way?

cheers
david

1 post - 1 participant

Read full topic

How to render Stencil WebComponents in Jest environment?

$
0
0

Greetings!

First of all, thank you in advance for your support!

I’m trying to render WebComponents created using StencilJS in a Vue app in Jest environment, but I can’t seem to get it to work.

I’ve put up a minimum repo that you can check here: https://github.com/gassiss/stencil-jest
I’ve essentially just glued together the initial boilerplate from Vue and StencilJS.

If you cd into hello-world folder and run npm run serve and run window.customElements.get('my-component') in the browser’s console, you’ll see that defineCustomElements function call works as intended.

The problem is in test environment. Please refer to example.spec.js line 10, which is commented out. When you run the tests, the console.log on line 14 returns undefined. Enable line 10 and it returns a web component.

I’ve tried looking everywhere, but it’s a very tricky topic to research for, as all I get is how to use Jest to test StencilJS components from the perspective of the person creating the Design System, but not from the perspective of the one using it.

Any help is greatly appreciated!

1 post - 1 participant

Read full topic


Ionic Framework 4.x React IonButton form attribute

$
0
0

Hey everyone,
i don’t think that there is a way to easily call a submit outside a form so i thought you might have some suggestions…

Example 1

<form id='test-form' onSubmit={ (e) => handleSubmit(e) }>
  <IonComponents>....</IonComponents>
</form>
<IonButton type='submit' form='test-form'>Submit</IonButton>

Doesn’t work/won’t comple since IonButton has no Attribute form, but

Example 2

<form id='test-form' onSubmit={ (e) => handleSubmit(e) }>
  <IonComponents>....</IonComponents>
</form>
<button type='submit' form='test-form'>Submit</button>

Example 2 also checks for form validation, which i wont get just calling the handleSubmit function.

The examples above are extremely simplified examples, but they work when i put the IonButton inside the form like this (form validation etc…:):

<form id='test-form' onSubmit={ (e) => handleSubmit(e) }>
  <IonComponents>....</IonComponents>
  <IonButton type='submit' form='test-form'>Submit</IonButton>
</form>

Any help is appreciated

1 post - 1 participant

Read full topic

Error: Can't resolve all parameters for AppComponent: ([object Object], [object Object], [object Object], [object Object], [object Object], [object Object], ?).

$
0
0

import { Component,OnInit, Injectable } from ‘@angular/core’;

import { MenuController,NavController } from ‘@ionic/angular’;

import { Platform } from ‘@ionic/angular’;

import { SplashScreen } from ‘@ionic-native/splash-screen/ngx’;

import { StatusBar } from ‘@ionic-native/status-bar/ngx’;

import { AngularFireAuth } from ‘@angular/fire/auth’;

import { ScreenOrientation } from ‘@ionic-native/screen-orientation/ngx’;

@Injectable()

@Component({

selector: ‘app-root’,

templateUrl: ‘app.component.html’,

styleUrls: [‘app.component.scss’]

})

export class AppComponent implements OnInit {

userEmail: string;

constructor(

private platform: Platform,

private splashScreen: SplashScreen,

private statusBar: StatusBar,

public menu: MenuController,

private afAuth: AngularFireAuth,

private navCtrl:NavController,

private screenOrientation:ScreenOrientation,

) {

this.initializeApp();

}

ngOnInit() {

this.afAuth.user.subscribe(res => {

  console.log('res', res);

  if (res !== null) {

    this.userEmail = res.email;

  } 

}, err => {

  console.log('err', err);

})

this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.PORTRAIT);

}

logout() {

this.afAuth.signOut()

  .then(res => {

    console.log(res);

    this.navCtrl.navigateBack('/thanks');

  })

  .catch(error => {

    console.log(error);

  })

}

initializeApp() {

this.platform.ready().then(() => {

  this.statusBar.styleDefault();

  this.splashScreen.hide();

});

}

enableAuthenticatedMenu() {

this.menu.enable(true, 'authenticated');

this.menu.enable(false, 'unauthenticated');

}

}

1 post - 1 participant

Read full topic

I need to implement search function in my app and am not sure how to do it

$
0
0

home.html


<ion-title *ngIf="!showSearchbar">

Likatkatә Miya Fal Hyel


<ion-buttons slot=“start” *ngIf="!showSearchbar">


<ion-searchbar [(ngModel)]=“searchTerm”
(ionChange)=“setFilteredItems()”
placeholder=“Search Song & title”
*ngIf=“showSearchbar”
showCancelButton= “always”
(ionCancel) = “showSearchbar=false”
>

<ion-buttons slot =“end” ion-button icon-only *ngIf="!showSearchbar" (click) =“showSearchbar=true”>



{{item.id}}

{{item.title}}

home.ts
import { Component, OnInit } from ‘@angular/core’;
import { DatabaseService, Song } from ‘…/services/database.service’;
import { Platform } from ‘@ionic/angular’;
import { HttpClient } from ‘@angular/common/http’;
import { Observable } from ‘rxjs’;

@Component({
selector: ‘app-home’,
templateUrl: ‘home.page.html’,
styleUrls: [‘home.page.scss’],
})
export class HomePage implements OnInit {

song: Song = ;

songs: Observable<any>;

public items: any = ;
public filterItems = ‘’;

showSearchbar: boolean;
constructor( public http: HttpClient, private db: DatabaseService, private platform: Platform) {
this.platform.ready().then(() => {
}).catch(error => {
console.log(error);
});
}

ngOnInit() {
this.setFilteredItems();
this.db.getDatabaseState().subscribe(rdy => {
if (rdy) {
this.db.getSong().subscribe(content => {
this.song = content;
});
}
});
}

setFilteredItems() {
this.items = this.db.filterSearch(this.filterItems);
}

}

//This what i have been doing from order tutorials on my db.ts page
filterItems() {
return this.database.executeSql('SELECT * FROM song ', ).then(data => {
const items: Song = ;
if (data.rows.length > 0) {
for (let i = 0; i < data.rows.length; i++) {
items.push({
id: data.rows.item(i).id,
title: data.rows.item(i).title,
verse1: data.rows.item(i).verse1,
verse2: data.rows.item(i).verse2,
verse3: data.rows.item(i).verse3,
verse4: data.rows.item(i).verse4,
verse5: data.rows.item(i).verse5,
verse6: data.rows.item(i).verse6,
});
}
}
this.items.next(items);
});

}

filterSearch(filterItems) {
return this.items.filter(items => {
return items.id.toLowerCase().indexOf(filterItems.toLowerCase()) > -1
|| this.items.title.toLowerCase().indexOf(filterItems.toLowerCase()) > -1;
});
}

Please help me, i want to filter the list of songs on the home page.

1 post - 1 participant

Read full topic

Sending Questions list with Ion-toggle values

$
0
0

Hi All

I am testing Ionic 5 to use to build a side project.

I have a section where I ask users 7 questions and two of those have input fields while the other 5 require a yes or no answer.

So the questions with toggle must default to false(No) on page load then as user changes the selection then those be sent when user submits the form after answering all 7 questions.

I want to save the first 5 questions as an object and the other two are fine.

So I want to have something like this. screening data will be the combined 5 questions into one object with question id, description and toggle value (yes/no)

{
"user_id":15,
"score":45,
"company_id" : 39,
"additional_info":"visit",
"screening_data": [
    {"id": 1 , "description": "description goes here 1", "answer" : "yes"},
    {"id": 2 , "description": "description goes here 2", "answer" : "no"},
    {"id": 3 , "description": "description goes here 3", "answer" : "yes"},
    {"id": 4 , "description": "description goes here 4", "answer" : "no"},
    {"id": 5 , "description": "description goes here 5", "answer" : "yes"}
  ]
}

One Submission I will be sending to backend via api.

I would like your assistance with this.

Thanks

3 posts - 2 participants

Read full topic

Why cordova background geolocation doesn't work as my expection?

$
0
0

I use cordova background geolocaiton plugin in my ionic 3 application.

    ionic cordova plugin add cordova-plugin-mauron85-background-geolocation@alpha
    npm install --save @ionic-native/background-geolocation@4

I expect the plugin work in background, once the device is moved over 40 meters, the plugin will trigger this.backgroundGeolocation.on(BackgroundGeolocationEvents.location) once, My code is like:

startBackgroundGeolocation() {
    const config: BackgroundGeolocationConfig = {
      desiredAccuracy: 10,
      stationaryRadius: 20,
      distanceFilter: 40,
      debug: true, //  enable this hear sounds for background-geolocation life-cycle.
      stopOnTerminate: false // enable this to clear background location settings when the app terminates
    };

    this.backgroundGeolocation.configure(config).then(() => {
      this.backgroundGeolocation
        .on(BackgroundGeolocationEvents.location)
        .subscribe((location: BackgroundGeolocationResponse) => {
          console.log("!!!!!!!!!!!!!!!!!!!!!!!!!! background geolocation !!!!!!!!!!!!!!!!!!!");
          console.log(location);
        });
    });
    this.backgroundGeolocation.start()
  }

But after backgroundGeolocation start, I find the behavior is not like my expectation.

  1. this.backgroundGeolocation.on(BackgroundGeolocationEvents.location) is triggered about ever 30 seconds without any device movement
  2. this.backgroundGeolocation.on(BackgroundGeolocationEvents.location) has been triggered many times, and the number of times increases one every ~30 seconds

for example, when it is first triggered, the log shows:

!!!!!!!!!!!!!!!!!!!!!!!!!! background geolocation !!!!!!!!!!!!!!!!!!!

in about 30 seconds, it is second triggered, log shows:

!!!!!!!!!!!!!!!!!!!!!!!!!! background geolocation !!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!! background geolocation !!!!!!!!!!!!!!!!!!!

in next about 30 seconds, it is third triggered, log shows:

!!!!!!!!!!!!!!!!!!!!!!!!!! background geolocation !!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!! background geolocation !!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!! background geolocation !!!!!!!!!!!!!!!!!!!

and so on.

I want .on(position) only be triggered when movement over 40 meters, and when it is triggered, just triggered once.

!!!!!!!!!!!!!!!!!!!!!!!!!! background geolocation !!!!!!!!!!!!!!!!!!!

I think there must be something wrong with my configuration setting, but I could not find the problem in the setting.

Could you please help if you familiar with cordova-background-geolocation plugin?

Thanks

2 posts - 2 participants

Read full topic

Viewing all 70913 articles
Browse latest View live