How can I disable Pushy in Capacitor using Ionic Toggle? - ionic-framework

Is there a way to disable Pushy, in Capacitor, using Ionic Toggle? There are no function in the pushy documentation: https://pushy.me/docs/additional-platforms/capacitor
The goal is to have a toggle switch for enabling/disabling Pushy.
Something similar this?
async pushyToggle() {
if (isPush == true) {
await enablePushy();
}
else if () {
await disablePushy();
}
}
I think I might be doing it all wrong. Need help. Thanks!

You can call Pushy.unregister() to stop the device from receiving notifications, as mentioned in the Pushy Android SDK docs and Pushy iOS SDK docs. This method is also supported in the Pushy Cordova SDK which Capacitor support depends on.
Invoke this method to unregister the device from receiving notifications. Calling Pushy.register() on the device in the future will (in most cases) restore the device token which was previously assigned to the device.
Full disclosure: I work at Pushy.

Related

How to get heading value from location plugin from ios? Flutter

I'm using location plugin with Google maps for flutter. When I try to give rotation to custom marker, android works perfectly but ios always returns -1. I tried flutter_compass but i read this plugin does not work Huawei, Xiaomi. What Can I do to solve this problem?
One way (probably not ideal) is to use location on Android and flutter_compass on iOS. You can perform a simple platform to see which one you're on:
if (Platform.isAndroid) {
// use location
else if (Platform.isIOS) {
// use flutter_compass
}
If the issues of flutter_compass with certain devices ever get patched, you can simply delete the check and use flutter_compass on both platforms.

Ionic 5 + Capacitor with Huawei HMS

I've build an app using Ionic 5 (Angular) and Capacitor. I'm using the Capacitor plugin for Push Notifications. All is working fine on both iOS and Android. However on Huawai phones (P30 and later) things don't work properly.
No device id is obtained and Push Notifications don't work, even the PushNotifications.addListener('registration', async (token: PushNotificationToken) => {}) is not triggered.
Any ideas on what I need to do so that I can maintain one codebase and make it work on both Android "worlds" (Google & Huawei) ?
Thanks in advance,
Chris
Probably the Ionic plug-ins you used are provided for GMS and Firebase so that their capabilities can be directly called in Ionic. Therefore, apps developed by Ionic must directly call HMS capabilities when Google Play services are unavailable.
You are advised to use HMS Ionic plugin to integrate HMS Push Kit in Ionic App. You can get the Push Plugin from here. Please use 5.0.0 version.
Or you can get it from npmjs here.
Update:
If you look for a way which allows you to use both push notifications in the same application by detecting the device type and acting accordingly, you can use G+H solution. Using the G+H approach, you are able to maintain one codebase and decide whether to use GMS or HMS based on the availability of either one.
From: https://stackoverflow.com/a/63337530/13329100

Onesignal promptPermission() is not applicable in Android

i'm using onesignal_flutter to push notifications to my app, but im facing this error, i did everything in the docs, still facing the same problem, any solution ?
In my case on Android I remove this line await OneSignal.shared.promptUserForPushNotificationPermission();

Is there any way to detect if it runs on web or not?

I'm playing with flutter for web and am wondering if there is a way to detect it runs on web or mobile.
Like you can detect iOS or Android like so.
if (Theme.of(context).platform == TargetPlatform.iOS)
Does anyone know that?
There was another question here.
The solution is to use the global constant if (kIsWeb) {...}
Documentation: https://api.flutter.dev/flutter/foundation/kIsWeb-constant.html
OLD ANSWER:
Flutter Web are in Preview Mode in another branch of the main Flutter.
I think when officially release a stable version you can to use something like Platform.isWeb, for while the better option are wait or use Platform.isWindows or any other SO.

How to integrate "Google Firebase Analytics" in ionic apps?

In the official Firebase Integration Guide (Android) and Firebase Integration Guide (iOS), they have provided individual integration guidelines.
Could you please tell me an ionic way I can integrate Firebase Analytics into ionic apps?
I need to do this as AdMob made the Firebase Analytics as its recommendation analytics solution for mobile apps.
Thank you in advance.
Worth keeping any eye on this thread:
https://groups.google.com/forum/#!topic/firebase-talk/MKfIzAtNNuA
In the meantime, an Ionic Native plugin on top of the Cordova plugin cordova-plugin-firebase-analytics has been released: https://ionicframework.com/docs/native/firebase-analytics/
It's still in beta, but I had no problems with it so far (except for a conflict with phonegap-plugin-push).
The integration is very straight forward:
import { FirebaseAnalytics } from '#ionic-native/firebase-analytics';
constructor(private firebaseAnalytics: FirebaseAnalytics) { ... }
To track an event just call logEvent:
this.firebaseAnalytics.logEvent('page_view', {page: "dashboard"})
.then((res: any) => console.log(res))
.catch((error: any) => console.error(error));
Looks like someone created a repository for Firebase in Cordova, you should be able to use that. It says that it will give you at least push notifications, analytics, event tracking, crash reporting.