s$ = new BehaviorSubject<string[]>([]);
s$.subscribe(ar => { doStuff() });
s$.value[0] = "foo"; // will *not* fire the above subscription
{
let sv = s$.value;
sv[0] = "foo";
s$.next(sv); // *will* fire the above subscription
}
Ionic 4: View not updating after recieving push notification
Ionic 4: View not updating after recieving push notification
I added this, and let all other code like it was in the subscibe, but now nothing is happening at all, I don’t even get the console log, that there was a notification.
this.firebase.onMessageReceived()
.pipe(msg => of(msg))
.subscribe(
(res => {
console.log("this notification", res)
}))
URL open inside the app
This sounds like precisely the sort of thing that the concept of PWA was intended to address. You should be able to make your “Webview app” installable and seem to users like an app, but it will act like a bookmark to your “Webview app”.
Ionic 4: View not updating after recieving push notification
Sorry, my bad, doing three things at once, all poorly.
pipe(switchMap(msg => of(msg))
Ionic 4: View not updating after recieving push notification
Thanks, good to know, but I use next
in the in this if
:
if (res.halterid == this.chatService.chat_partner.value.id){
this.activeChat.next(true)
The all_stored_chats
Subject could also be a normal variable at that point, because I think I removed the part where it was necessary to subscribe to it, and no problem, don’t stress yourself
URL open inside the app
There is a PWA plugin. Can PWA send forum notifications too ? I will check.
I am know that Stencil can build PWA. But I am not skilled enough to do it.
Ionic 4: View not updating after recieving push notification
Ok that worked, I’m getting my console logs again, the test()
function gets called, I see the console log and the dummy object got pushed into the my_active_chat["nachrichten"]
array. But I still didn’t see this dummy message in the view.
Ionic 4: View not updating after recieving push notification
To recap a bit, you originally said:
So we can split the problem in half:
A. Getting my_active_chat["nachrichten"]
updated
B. Reflecting A in the view
At the beginning of this conversation, I was under the impression that the problem was squarely in part A, because I took your “when I use a button everything is fine” to indicate that the button took care of A, and in that event, B worked as expected.
Now I’m hearing that A has been eliminated as a source of trouble, which would seem to also let push notifications off the hook.
What is different between the current state of affairs and the “manually pushing something into my_active_chat["nachricten"]
via a button” one?
Ionic 4: View not updating after recieving push notification
Yeah sorry, it’s late in germany… It was all the time about B.
I really have to say that I got no Idea what the difference is.
From the what is done perspective:
C. The push notification changes a Subject, that change calls a function that pushes someting into an array.
D. The push on a button only calls the same function where something is pushed into the array.
In the console both cases get executed, but only D is visible, because another textbox is created in the html page.
Maybe the button works, because I interact with the site directly and the push notification “only” calls functions in the site background?
Ionic 4: View not updating after recieving push notification
One further quick thing you can check:
- Inject a
ChangeDetectorRef
into your page constructor. - At some point after the array has been modified, call its
detectChanges
method.
If that works, then Angular’s change detection is failing to pick up your change for some reason. This used to be a much more common and insidious problem back in the AngularJS days, but I guess it’s conceivable that it could still bite one under some conditions.
Ionic 4: View not updating after recieving push notification
Thanks that was the solution, all works now
Or atleast the test case, I will check if works with the http request too and reply again then.
Ionic 4: View not updating after recieving push notification
It works with the real version too, thanks a lot
Ionic 4: View not updating after recieving push notification
In the long term, it’s probably best to try to figure out exactly why change detection isn’t triggering, but at least this should band-aid it for now.
Ion-slides replacement swiperjs not snapping
I have got swiperjs working in Ionic/Angular and used the fix below for getting the slides to “snap” rather than free flow. However this causes an issue with resetting the slide index to 0 if the page is changed and then the user returns to the swiper.
Does anyone know any other solutions to get the swiper to Snap?
Ion-slides replacement swiperjs not snapping
Solution:
Bug: menu hamburger crash app
Hello i open issus from github but closed and redirected here bug: menu hamburger crash app · Issue #23684 · ionic-team/ionic-framework · GitHub
Current Behavior
i start my app on ios i click on the menu but the app stop working check this videos for more for unbug the app i need to slide from the right and click home and app working again
Bug menu - YouTube (on 0.04 check the button it flashes when I click on it)
Expected Behavior
the menu open without crash
Steps to Reproduce
I cannot provide you with this information
Code Reproduction URL
No response
Ionic Info
Ionic:
Ionic CLI : 6.16.3 (C:\Users\PC01\AppData\Roaming\npm\node_modules@ionic\cli)
Ionic Framework : @ionic/angular 5.6.3
@angular-devkit/build-angular : 0.1102.5
@angular-devkit/schematics : 11.2.5
@angular/cli : 11.2.5
@ionic/angular-toolkit : 3.1.1
Capacitor:
Capacitor CLI : 2.4.7
@capacitor/android : 2.4.7
@capacitor/core : 2.4.7
@capacitor/ios : 2.4.7
Utility:
cordova-res : not installed globally
native-run : not installed globally
System:
NodeJS : v14.17.0 (C:\Program Files\nodejs\node.exe)
npm : 6.14.13
OS : Windows 10
After taking a photo using capacitor camera the App exits
Hi All,
I have an app built using ionic vue and capacitor 3 which uses the capacitor camera. As soon as the photo is taken the app exits. Also, I have plenty of space in my android which makes this scenario bit strange to me. Here’s my code… have I missed anything. Please point me in the right direction.
<template>
<ion-page>
<ion-header>
<ion-toolbar color="primary">
<img src="../assets/logo.svg" class="LogoSvg" />
</ion-toolbar>
</ion-header>
<ion-content>
<ion-img :src="image" v-if="image && !cameraActive"></ion-img>
<ion-button @click="sendPhoto" expand="full" v-if="image && !cameraActive">Send</ion-button>
</ion-content>
</ion-page>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue';
import {
IonPage,
IonHeader,
IonToolbar,
IonContent,
onIonViewWillEnter
} from "@ionic/vue";
import { useStore } from "vuex";
import { isEmpty, isNil } from "lodash";
import FileUploadBase64 from "@/dtos/FileUploadBase64";
import router from "@/router";
import { Camera, CameraDirection, CameraResultType, CameraSource } from '@capacitor/camera';
export default defineComponent({
name: "Camera",
components: {
IonPage,
IonHeader,
IonToolbar,
IonContent
},
setup() {
const store: any = useStore();
const image = ref("");
const toOcr = ref("");
const cameraActive = ref(false);
const sendPhoto = async () => {
if (image.value.length > 0) {
const fileUpload = new FileUploadBase64();
fileUpload.fileContent = toOcr.value.toString();
// API call goes here
router.push('/tabs/deceased');
}
};
const takePhoto = async () => {
cameraActive.value = true;
const photo = await Camera.getPhoto({
resultType: CameraResultType.Base64,
source: CameraSource.Camera,
quality: 100,
direction: CameraDirection.Rear
});
const base64ImageResult = photo.base64String;
if(!isNil(base64ImageResult) && !isEmpty(base64ImageResult)) {
image.value = base64ImageResult;
cameraActive.value = false;
}
};
onIonViewWillEnter(async () => {
await takePhoto();
});
return {
image,
toOcr,
sendPhoto,
cameraActive,
takePhoto
};
}
});
</script>
Capacitor 3 not registereing plugin automatically in MainActivity
I have upgraded from capacitor 2 to capacitor 3 . The issue I am facing on both plugins push notifications and background geolocation . Getting same error that is “Plugin not implemented for android”
According to the docs it should automatically register in MainActivity.java file but that is not happening I have to remove init method from that file
package siloc.xyz;
import android.os.Bundle;
import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Plugin;
import java.util.ArrayList;
import com.hemangkumar.capacitorgooglemaps.CapacitorGoogleMaps;
import com.getcapacitor.community.bglocation.BackgroundGeolocation;
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
}
What is the problem here?
--keyboard-offset bind to the ion-content styling breaks layout
So do I. Whenever I click on a radio/checkbox (in my case), then ‘focusin’ events happens. This is what I doing to work around:
<div (focusin)="focusin($event)">
...
<input type="radio />
...
</div>
focusin(evt) {
evt.stopPropagation();
}
No keyboard animation on ion-footer
You can restart the whole thing, may be this will work.