Quantcast
Channel: Ionic Forum - Latest posts
Viewing all 228535 articles
Browse latest View live

Push Notifications with Image

$
0
0

I added the extension as a new ‘Target’ in xcode. I added it as a Notification Service Extension.

Does this help?

Here’s the code for that Notification Extension:

import UserNotifications
import Firebase

class NotificationService: UNNotificationServiceExtension {

    var contentHandler: ((UNNotificationContent) -> Void)?
    var bestAttemptContent: UNMutableNotificationContent?

    override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
        self.contentHandler = contentHandler
        bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
        
        if let bestAttemptContent = bestAttemptContent {
            // Modify the notification content here...
            //bestAttemptContent.title = "\(bestAttemptContent.title) [modified]"
            
            Messaging.serviceExtension().populateNotificationContent(self.bestAttemptContent!, withContentHandler: contentHandler)
            //contentHandler(bestAttemptContent)
        }
    }
    
    override func serviceExtensionTimeWillExpire() {
        // Called just before the extension will be terminated by the system.
        // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
        if let contentHandler = contentHandler, let bestAttemptContent =  bestAttemptContent {
            contentHandler(bestAttemptContent)
        }
    }


}


Angular ngFor not iterating through array on Android

$
0
0

For the record, what I suspect was happening is that you (rightly) got used to HttpClient dealing with the tedium of JSON marshalling and unmarshalling for you. Native HTTP plugins don’t provide that service, so you were inadvertently trying to treat a JSON string representation as an unmarshalled object.

In any event, glad it’s working for you now.

Social Sharing Remote Images

$
0
0

Is there any option out there that provides native social sharing for iOS & Android and allows sharing of remote files?

I’ve got standard sharing working with “@capacitor/share” however in order to share a file with that plugin it would have to be a local file. We’re trying to allow our members to share images hosted on our website without having to download the image first.

So then I found “@byteowls/capacitor-filesharer” and got that setup and running without errors, however that plugin is just doing nothing now. When I run ionic serve, and click the share button this plugin downloads the image to my computer. If I run ionic capacitor run android and open the app on my device, then click the share button, nothing happens. The console shows a response in the success callback but no share menu shows at all.

Am I doing something wrong? Is there a better plugin? Is this not possible right now?

How do you use Gestures API in a Vue Component?

$
0
0

@ldebeasi hi! Although I get no error, the onStart or onEnd handlers do not fire. I copied the example directly from Ionic docs, so I am wondering what else I am doing wrong?

IonTabs does not show at first render

$
0
0

The problem I have is that Tabs, element containing is not displayed the first time the component is rendered. If instead it is shown when I return the Elements component.

Consider that at the moment tabs does nothing because it is part of the design at the current stage

    return (
      <div id="container-principal-ExplorerContainer-Cliente">   
        <Tabs setShowModal={props.setShowModal} setTipoDeVistaEnModal={props.setTipoDeVistaEnModal} ></Tabs>
        <IonTitle id="explorerContainerCliente-titulo">PROVEEDORES DE SERVICIOS EN LA ZONA </IonTitle>             
        <Elements  arrangement={props.arreglo!} setVerEmail={setVerEmail} setItem={setItem}  />
      </div>
      );
const Tabs= (props:{setShowModal:any,setTipoDeVistaEnModal:any }) => {

  return(
    <>
    
    <IonReactRouter>

    <IonTabs>

        <IonRouterOutlet>
          <Route exact path="/">
          </Route>
          <Route exact path="/">
            <Tab2 />
          </Route>
          <Route path="/">
          </Route>
          <Route exact path="/">
            <Redirect to="/" />
          </Route>
        </IonRouterOutlet>

        <IonTabBar slot="top">

          <IonTabButton tab="tab1" href="/tab1">
            <IonIcon icon={triangle} />
            <IonLabel>CATEGORÍAS</IonLabel>
          </IonTabButton>
          
          <IonTabButton tab="tab2" href="/tab2">
            <img className="imagen-boton-principal" src={"./assets/icon/sirena.png"} />
            <IonLabel>EMERGENCIAS</IonLabel>
          </IonTabButton>

          <IonTabButton tab="tab3" href="/tab3">
          <img className="imagen-boton-principal" src={"./assets/icon/time.png"} />
            <IonLabel>PROGRAMAR</IonLabel>
          </IonTabButton>
       
        </IonTabBar>
      </IonTabs>
      </IonReactRouter>
      </>
  )
}

How do you use Gestures API in a Vue Component?

$
0
0

O, it has to be in onMounted() otherwise it doesn’t work. All good now. Thanks!

How do you use Gestures API in a Vue Component?

$
0
0

One last question: would you happen to know how I bind my Vue methods: {} functions to the gesture? I need it to interact with the Vue component but the handlers in the Gesture API example are all isolated inside the setup() function.

Debugging published android app whitescreen

$
0
0

I inherited an Ionic v5 angular project which was using build tools from 2018/2019. After upgrading everything I could (ionic, cordova, gradle, android studio, etc) and resolving errors, I am experiencing an app that fully works any way I try to run it except after it has been deployed.

The app gets stuck at the splash screen but only after it has been published to the play store. This app works on iOS store. From what I can tell it seems to be breaking when trying to ask for permissions but I don’t know how to find logs.

This occurs whether I build and deploy the app manually or using App Flow.

How do I go about debugging an issue that only appears on live?


Disable ion-datetime picker scroll vibration

How do you use Gestures API in a Vue Component?

$
0
0

If you use the mounted() lifecycle option, you should have access to your methods. You may need to setup the gesture in this.$nextTick in order to ensure all child components have been rendered. See Lifecycle hooks | Vue.js for an example

Dependency injection in tabs

$
0
0

New to ionic, intermediate level on Angular. . .
Normally in Angular I have only one root module “app.module.ts” where I declare my providers which are nicely injected throughout all the components.

I am trying to inject one and only one instance of a data service throughout all the tabs so that I can share data across the tabs.
I included this DataService in app.module.ts providers, but not sure how to pass it on to the other tabs?

Each tab is loaded in app-routing.module.ts, for example:
{
path: ‘home’,
loadChildren: () => import(’./components/home/home.module’).then( m => m.HomePageModule)
},

How do I do dependency injection across modules in this case?

Thank you!

Dependency injection in tabs

$
0
0

IMHO this is a reasonable strategy, and it works perfectly well with Ionic apps. You’re not required to split everything into lazily-loaded modules. I don’t. There is just too much tedious boilerplate and opportunity for stupid wiring bugs like this, and not nearly enough benefit in ordinary, non-behemoth-sized apps.

You shouldn’t have to do anything special here. Services that are provided in the app module are associated with the root injector, and will be present in any other NgModules. Where it gets trickier is when you’re providing the service in a feature module.

So if you’re posting this as a preemptive question, my answer is “don’t worry about it”. If you’re posting it because something isn’t working as you expected, please post enough additional code for others to be able to reproduce your problematic behavior.

Android 10 Camera Plugin Issues

$
0
0

My capacitor app uses the Camera plugin to take pictures and/or allow the user to select photos from the gallery. In Android 7, iOS, and on the web, the app works correctly. In Android 10, the gallery works, but the camera does not. There are two issues:

First, in Android 10, the camera does not save the image to the gallery, but in Android 7 it does. The code for launching the camera is:

import { Camera, CameraResultType, Photo, CameraSource } from '@capacitor/camera';
import { CameraHelper } from "./CameraHelper"; // This hooks into a custom webpack build rule for bundling PWA on web, but not including on Android/iOS

export function takePicture(success: (image: string) => void, failure: (reason: any) => void) {
    let f = () => {
        Camera.getPhoto({
            quality: 90,
            allowEditing: false,
            direction: CameraDirection.Front, // Commenting this does not change the behavior
            resultType: CameraResultType.Uri,
            source: CameraSource.Camera,
            saveToGallery: true  // Commenting this does not change the behavior
        }).then((image: Photo) => {
            success(image.webPath!);
        }).catch((reason: any) => {
            failure(reason);
        });
    }
    // NB: on web/electron, need to load PWA support first
    if (platform === "web") {
        new CameraHelper().injectPwa(f);
    }
    else {
        f();
    }
}

Second, my Android 10 device stops the activity when it switches to the camera, but I don’t get an appRestoredResult when my app restarts. To be clear: I understand that the Android lifecycle allows for the app to stop and be restarted. That’s not my issue. My issue is that I make a checkpoint, but since I am not getting an appRestoredResult event, I can’t restore my checkpoint. The code for listening for restart runs immediately when the app begins (not called from an async/await function):

App.addListener('appRestoredResult', (event: RestoredListenerEvent) => {
    console.log('Restored state:', event.data);
    console.log('Restored state:', event.error);
    console.log('Restored state:', event.methodName);
    console.log('Restored state:', event.pluginId);
    console.log('Restored state:', event.success);
}).then((v: PluginListenerHandle) => {
    console.log("Handler installed");
});

While “Handler installed” does get printed to the log, the other messages do not… No event ever fires.

To chase this down, I started putting Log.d messages into CameraPlugin.java file, to see where things break. Things go badly right away:

    public void processCameraImage(PluginCall call, ActivityResult result) {
        if (imageFileSavePath == null) {
            // processCameraImage() is always returning here, because imageFileSavePath is null
            call.reject(IMAGE_PROCESS_NO_FILE_ERROR);
            return;
        }
        // ...
    }

In retrospect, it makes sense that when the imageFileSavePath is null, the app won’t get an appRestoredResult event, because there is nothing to use to restore. And if the camera plugin isn’t working correctly, then it would make sense for imageFileSavePath to be null. So my guess is that the second problem will go away if I can figure out why the camera isn’t saving its picture to the gallery, or anywhere else.

The only thing I can think of is that there is some kind of misconfiguration of permissions in my app, which is causing the Camera to fail. But I cannot find any advice online about configuration changes for Capacitor and/or the Camera plugin for Android 10. And as stated earlier, the code works on Android 7, iOS, and PWA/Web.

Here are the important parts of the app’s configuration. First, the manifest’s permissions:

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
    <uses-permission android:name="com.android.vending.BILLING" />

    <application
        android:allowBackup="true"
        android:fullBackupOnly="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:hardwareAccelerated="true"
        android:requestLegacyExternalStorage="true">
// ...

Next, variables.gradle:

ext {
    minSdkVersion = 21
    compileSdkVersion = 29
    targetSdkVersion = 29
    andridxActivityVersion = '1.2.0'
    androidxAppCompatVersion = '1.3.1'
    androidxCoreVersion =  '1.3.2'
    androidxMaterialVersion =  '1.1.0-rc02'
    androidxBrowserVersion =  '1.2.0'
    androidxLocalbroadcastmanagerVersion =  '1.0.0'
    androidxExifInterfaceVersion = '1.2.0'
    firebaseMessagingVersion =  '20.1.2'
    playServicesLocationVersion =  '17.0.0'
    junitVersion =  '4.12'
    androidxJunitVersion =  '1.1.3'
    androidxEspressoCoreVersion =  '3.4.0'
    cordovaAndroidVersion =  '7.0.0'
}

Finally: here is my npx cap doctor result:

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 3.2.0
  @capacitor/core: 3.2.0
  @capacitor/android: 3.2.0
  @capacitor/ios: 3.2.0

Installed Dependencies:

  @capacitor/ios: not installed
  @capacitor/cli: 3.2.0
  @capacitor/android: 3.2.0
  @capacitor/core: 3.2.0

[success] Android looking great! 👌
[error] Xcode is not installed

Any suggestions would be greatly appreciated!

Dependency injection in tabs

$
0
0

Thanks very much!
I have done a few tests with a behaviorsubject(), I called next() in the app.module and when I switch tab I can see that the subject has an array of objects which proves that it is the same instance updated by the app.module. So Angular DI is more magic that I thought :slight_smile:, so in short this is not an issue as I thought.

Re lazily loading modules, I am doing that cause that’s the code that I got from running “ionic create” cli wizard and I simply thought there would be some good reason for it. I guess the only advantage would be a slightly faster startup depending on the complexity of the code, right?

I am going to ditch this pattern also because it’s not very readable and a bit spaghetti :smiley:

Dependency injection in tabs

$
0
0

This is why I disagree so strongly with the Ionic team’s decision here. Everybody gets intimidated by the generators and cowed into accepting this choice to drastically complicate the structure of their app.

Yes, and depending on how much smarter webpack has gotten since I last dove deeply into the internals of all this (which, in fairness, was several years ago - you can start down the rabbit hole with ng-cli #2771), even that advantage may be mitigated by the code duplication incurred as overhead to support the whole lazy loading architecture.

Welcome to the resistance. :wink:


Npm run build does not make web assets directory ./www

$
0
0

React app! I changed it to build instead of www and it works because React builds into build and not www. Thanks!

Npm run build does not make web assets directory ./www

$
0
0

I just had to change it to build instead of www in the config file and it works because I am making a React app.

Android not working Mapbox on ionic 4 with capacitor?

$
0
0

I have the same problem right now, did you ever find an answer?

Using the VueJS Composition API to Create Hooks for Supabase Database and Storage

$
0
0

Using the VueJS Composition API to Create Hooks for Supabase Database and Storage

video walkthrough and source code available in video comments.

How to write the perfect Marketing CV?

$
0
0

Today the world of business is run by marketers. Every company invests in a good marketer to promote their brand better and win customers. Therefore, if you are looking to become a marketer or are in the marketing profession, it is necessary that you have an impeccable CV.
Resume Writer India

It comes as a shock that many marketers who can promote products and achieve promotional goals, struggle to put together an impressive CV. Thus, missing out on some of the opportunities that they could do well at.

Your CV is your elevator pitch, so if you cannot sell yourself then it reflects poorly on your abilities. Besides a good profile presentation is important. Therefore, it is essential that you get your CV professionally designed to be ahead of the lot.

For your CV to attract attention, you need to know your target audience. In this case, the company that is offering the job? What techniques do they use? How you can improve their products and gain better results?

Once you know what the hiring company needs, tailor your resume to fit their requirements. You should also highlight your strengths in the industry. Like, are you good at online marketing or offline? When displaying your strengths, ensure they all are relevant to the position you are applying into.

What goes into the CV?

1. Personal Information

At the top of your CV, provide your full name, nationality, address, email address, and phone number. The information will make it easier for potential employers to reach you for an interview.

2. CV Profile

Next, add a summary highlighting your attributes and experiences that are relevant to the job. This speaks to the recruiter as to why they should consider you for the position.

3. Educational Background

Provide a breakdown of your educational history from the highest level to the lowest. Since, it is a competitive space, adding a professional course or conference can make a difference. Besides, these additional certifications showcase your passion and commitment to succeed in the field.

4. Work Experience

When giving your employment history, refrain from listing your roles. Instead, state how you made a difference. You should also use standard industry terms to highlight your knowledge in the field.

5. Skills

List down the core and soft skills you have that are in line with the position that you are applying for. At times even if you have no experience, include attributes you acquired in college. Elaborate on your specialised marketing abilities and personal traits that will be relevant to the job you are seeking.

6. Personal Interest

It is an optional section where you mention your hobbies and your passions. The hobbies will give the impression that you are a whole-rounded person. However, do not lie about your hobbies.

With the basics right, there is no stopping to your career growth. Remember when you send your CV to a recruiter you are promoting yourself. And when it’s your career on the line, make sure to brand yourself and your abilities to the fullest.

Click here for marketing CV

Viewing all 228535 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>