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

Load styles in Ionic dynamically from a file downloaded via http

$
0
0

I just did this in our Ionic Vue app. I think your problem is that you are doing setStyle instead of setProperty.

Here is what we are doing:

private configureColors(group: GroupModel): void {
    const rootElm = document.querySelector(':root') as HTMLElement

    group.colors.forEach(color => rootElm.style.setProperty(color.name, color.value))
}

private removeColors(group: GroupModel): void {
    const rootElm = document.querySelector(':root') as HTMLElement

    group.colors.forEach(color => rootElm.style.removeProperty(color.name))
}

With our colors in this format:

{
    "colors": [
        {
            "name": "--ion-background-color",
            "value": "#f7fdff"
        },
        {
            "name": "--ion-background-color-rgb",
            "value": "247, 253, 255"
        },
        {
            "name": "--ion-color-primary",
            "value": "#2679ac"
        },
        {
            "name": "--ion-color-primary-rgb",
            "value": "38, 121, 172"
        },
        {
            "name": "--ion-color-primary-shade",
            "value": "#0e4567"
        }
    ]
}

We save out the custom colors in local storage and then set them every time the app launches.

In regards to the logo, we download it as a blob and save that out in local storage as a Blob itself. We then display it using URL.createObjectURL. We went with this over saving the logo/image to the file system as it’s simpler and doesn’t require a native plugin to interact with the file system.

Here is the full code. I know it is Vue, but you should give you some idea on how to implement.

<template>
    <div v-if="hasLogo && blobUrl != ''" class="mb-4 flex justify-center">
        <img
            class="max-h-16"
            :src="blobUrl"
            :alt="`${primaryGroup?.name} logo`"
            @load="handleLoaded"
        />
    </div>
</template>

<script setup lang="ts">
import { useGroupManager } from '@/groups/group-manager'
import { useGroupStore } from '@/stores/group-store'
import { computed, ref, watch } from 'vue'

const groupStore = useGroupStore()

const blobUrl = ref('')

const primaryGroup = computed(() => groupStore.groups.primary())
const hasLogo = computed(() => primaryGroup.value?.logo.url != null)

watch(
    () => primaryGroup.value?._is_downloading_logo,
    async isDownloading => {
        if (!isDownloading) {
            getLogo()
        }
    },
    { immediate: true },
)

async function getLogo(): Promise<void> {
    const data = await useGroupManager().getLogo() // A helper method to get blob from local storage

    if (data == null) {
        return
    }

    blobUrl.value = URL.createObjectURL(data)
}

function handleLoaded(): void {
    if (blobUrl.value === '') {
        return
    }
    
    // Clearing this doesn't cause the image to disappear. It stays rendered.
    URL.revokeObjectURL(blobUrl.value)
}
</script>

Form moves up when ion-input fields get focus

$
0
0

Did anyone get a solution for this in the end?

Show Metal Performance HUD on iOS device

Capacitor community plugins camera-preview and video-recorder conflicting

$
0
0

Have you set backgroundColor: '#ff000000', as the background color in your capacitor-config.ts?

Support JAVA 21 for latest Capacitor v7 support

$
0
0

yeah, Linux - 2025.01 was made available with JDK 21

Load styles in Ionic dynamically from a file downloaded via http

$
0
0

Thanks a ton!!

This really worked on my project!

I’ve been thinking about this issue for two days… and I didn’t really know how to approach the problem, and now that I have seen the solution, it makes me angry that I haven’t seen it before!

I really appreciate you taking the time to guide me through this.

Here you have a friend forever!

:hugs:​:fist_right:t3:​:fist_left:t3:

Capactor 7 on Android - Toolbar and Tab Bar - display issue

$
0
0

“fixed” it by setting padding-top: 20px on <ion-header> … if you’re using both mobile and web you can use Capacitor to check for the current platform and add or don’t a css class to the <ion-header> (in Vue you can do it with :class)

How to reuse floating labels?

$
0
0

not a good one. I mimicked the floating label:

:host {
  .input-wrapper {
    flex-grow: 1;
    display: flex;
    align-items: center;
    margin-top: calc($floating-font-size * 1.2 + $padding-top);
    min-height: utils.pxToRem(34); // 18 span + 2 * 8 inner padding

    > span {
      margin-right: 4px;
    }
  }

  label {
    position: absolute;
    inset: 50% 0 auto 0;
    color: var(--ion-color-medium, #92949c);
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    transform: translateY(-50%);
    pointer-events: none;
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
  }

  &.has-value label, &.input-has-focus label {
    inset: $padding-top 0 auto 0;
    transform: translateY(0);
    font-size: $floating-font-size;
  }
}

it looks as desired but I would recommend to look into Ionics GitHub and take their css rules instead


Show Metal Performance HUD on iOS device

$
0
0

Capacitor apps don’t use metal

Show Metal Performance HUD on iOS device

$
0
0

Isn’t Metal the only graphical API for iOS? My app has embedded a unity WebGL game, I imagine it does use metal.

Show Metal Performance HUD on iOS device

$
0
0

Looks like WebGL started using metal in some iOS 16.x version, but if you tried what you shared and didn’t work, probably Apple didn’t expose the HUD when using metal indirectly like on the WKWebView.

Angular navigate parent

$
0
0

Hi, when I am using angular router-outlet and I try for example

this.router.navigate(['/detail/' + id], { relativeTo: this.route.parent });

my navigation works OK
but when I switch to ion-router-outlet it stop working because this.route.parent is null
at the same time I tried to check children in parent and its null too while when I use angular router outlet I see all children of the parent
Am I missing some import in Ionic or is it how it should works ?

Setup Jest in Angular 14 + Ionic 6 project

Linking 3rd party swift packages

$
0
0

I am creating a capacitor plugin that wraps a 3rd party SDK. For IOS the SDK is available as a swift package. I am able to link the package to my plugin using the Package Dependencies tab in XCode after I build the app, but each time I build or run npx cap sync I need to relink the package.

I am wondering if there is a way to do this automatically with a build script or some other way so it doesn’t need to be done manually after each build.

How to change the font color of the label displayed as "Email"

$
0
0

Thank you.!!!!!!!!!!!


Setup Jest in Angular 14 + Ionic 6 project

$
0
0

i’m using this configuration:

globalThis.ngJest = {
    skipNgcc: true,
    tsconfig: 'tsconfig.spec.json', // this is the project root tsconfig
};

/** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
    preset: 'jest-preset-angular',
    testEnvironment: 'jsdom',
    setupFilesAfterEnv: [ '<rootDir>/src/setup-jest.ts' ],
    // setupFilesAfterEnv: [ '<rootDir>/node_modules/jest-preset-angular/build/setup-jest.js' ],
    transform: {
        '^.+\\.ts$': 'ts-jest', // Only transform .ts files
    },
    transformIgnorePatterns: [
        '/node_modules/(?!flat)/', // Exclude modules except 'flat' from transformation
    ],
    moduleNameMapper: {
        '\\.(css|scss)$': 'identity-obj-proxy',
        '^@/(.*)$': '<rootDir>/src/$1',
        '^app/(.*)$': '<rootDir>/src/app/$1',
        '^src/(.*)$': '<rootDir>/src/$1',
        '^shared/(.*)$': '<rootDir>/../shared/$1',
        '^mockServices/(.*)$': '<rootDir>/mockServices/$1',
        '^@app/(.*)$': '<rootDir>/src/app/$1',
        '^@environments/(.*)$': '<rootDir>/src/environments/$1',
    },
    moduleDirectories: [ 'node_modules', 'src' ],
    fakeTimers: {
        enableGlobally: true,
    }
};

It seems fine even though the tests… it’s quite more complicated than using Karma, pity they deprecated it :slightly_frowning_face:

Missing Privacy manifest - Ionic React

$
0
0

When publish app to Testflight I got this email. I am using Ionic React. Please let me know the solution.

ITMS-91061: Missing privacy manifest - Your app includes “Frameworks/GTMAppAuth.framework/GTMAppAuth”, which includes GTMAppAuth, an SDK that was identified in the documentation as a commonly used third-party SDK. Starting February 12, 2025, if a new app includes a commonly used third-party SDK, or an app update adds a new commonly used third-party SDK, the SDK must include a privacy manifest file or you won’t be able to submit the app for review in App Store Connect. Please contact the provider of the SDK that includes this file to get an updated SDK version with a privacy manifest. For more details about this policy, including a list of SDKs that are required to include signatures and manifests, visit: Upcoming third-party SDK requirements - Support - Apple Developer.

ITMS-91061: Missing privacy manifest - Your app includes “Frameworks/GTMSessionFetcher.framework/GTMSessionFetcher”, which includes GTMSessionFetcher, an SDK that was identified in the documentation as a commonly used third-party SDK. Starting February 12, 2025, if a new app includes a commonly used third-party SDK, or an app update adds a new commonly used third-party SDK, the SDK must include a privacy manifest file or you won’t be able to submit the app for review in App Store Connect. Please contact the provider of the SDK that includes this file to get an updated SDK version with a privacy manifest. For more details about this policy, including a list of SDKs that are required to include signatures and manifests, visit: Upcoming third-party SDK requirements - Support - Apple Developer.

ITMS-91061: Missing privacy manifest - Your app includes “Frameworks/GoogleSignIn.framework/GoogleSignIn”, which includes GoogleSignIn, an SDK that was identified in the documentation as a commonly used third-party SDK. Starting February 12, 2025, if a new app includes a commonly used third-party SDK, or an app update adds a new commonly used third-party SDK, the SDK must include a privacy manifest file or you won’t be able to submit the app for review in App Store Connect. Please contact the provider of the SDK that includes this file to get an updated SDK version with a privacy manifest. For more details about this policy, including a list of SDKs that are required to include signatures and manifests, visit: Upcoming third-party SDK requirements - Support - Apple Developer.

//package.json
@codetrix-studio/capacitor-google-auth”: “^3.4.0-rc.4”,

Missing Privacy manifest - Ionic React

Support JAVA 21 for latest Capacitor v7 support

$
0
0

I’m trying to create a project and I’m getting the same error

Get Appflow working with Nx monorepo based App repository

$
0
0

I’m attempting to get an app to build in Appflow, but without success. The app lives in an Nx Monorepo, therefore I’ve added the following appflow.config.json:

{
  "apps":
  [
      {
          "appId": "xxxxxxxx",
          "root": "apps/airsmart-user",
          "dependencyInstallCommand": "## yarn install && cd ../../ && yarn install",
          "webBuildCommand": "## cd ../../ && yarn nx build airsmart-user"
      }
  ]
}

with the correct appId. I’ve commented out the dependency and web build commands above. They caused the build to crash at that line when left in. Here’s that log results:

[05:46:35]: Installing Dependencies (in /builds/monkeytronics/air-smart/apps/airsmart-user)
[05:46:35]: $ yarn install && cd ../../ && yarn install
[05:46:35]: ▸ ➤ YN0000: · Yarn 4.0.1
[05:46:36]: ▸ ➤ YN0000: ┌ Resolution step
[05:46:36]: ▸ ➤ YN0001: │ Error: @capacitor/android@file:../../node_modules/@capacitor/android::locator=airsmart-user%40workspace%3A.: ENOENT: no such file or directory, lstat '/builds/monkeytronics/air-smart/node_modules/@capacitor/android'
[05:46:36]: ▸ ➤ YN0000: └ Completed
[05:46:36]: ▸ ➤ YN0000: · Failed with errors in 0s 82ms
[05:46:36]: Failed to install dependencies using custom command: 'yarn install && cd ../../ && yarn install'
 Shell command exited with exit status 1 instead of 0.
➤ YN0000: · Yarn 4.0.1
➤ YN0000: ┌ Resolution step
➤ YN0001: │ Error: @capacitor/android@file:../../node_modules/@capacitor/android::locator=airsmart-user%40workspace%3A.: ENOENT: no such file or directory, lstat '/builds/monkeytronics/air-smart/node_modules/@capacitor/android'
➤ YN0000: └ Completed
➤ YN0000: · Failed with errors in 0s 82ms

I have a capacitor.config.json & ionic.config.json in the root of the app itself. And this all seems to hang together when I build and serve the app locally.

Apologies if very obvious issues in my approach, but full disclosure - it’s not my area of expertise (hence, hoping to be able to lean on Appflow to make life a little easier).

Perhaps there is a step by step nx example available which would help in isolating the issues with my approach???

Viewing all 230517 articles
Browse latest View live


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