Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not changing Icon #19

Open
coderpr0grammer opened this issue Mar 19, 2024 · 1 comment
Open

Not changing Icon #19

coderpr0grammer opened this issue Mar 19, 2024 · 1 comment

Comments

@coderpr0grammer
Copy link

coderpr0grammer commented Mar 19, 2024

I'm trying to change the icon, Expo SDK 49, custom expo-dev-client.

My expo.plugins in app.json:

"plugins": [
      "expo-apple-authentication",
      "@react-native-firebase/app",
      "@react-native-firebase/auth",
      [
        "expo-build-properties",
        {
          "ios": {
            "useFrameworks": "static"
          }
        }
      ],
      "expo-localization",
      "expo-dynamic-app-icon",
      [
        "expo-dynamic-app-icon",
        {
          "gorg": { 
            "image": "./assets/gorg-icon.png", 
            "prerendered": true 
          },
          "little-gorg": {
            "image": "./assets/little-gorg.png",
            "prerendered": true
          }
        }
      ]
    ]
import { TouchableOpacity, View, Image } from "react-native";
import * as Haptics from "expo-haptics";
import { getAppIcon, setAppIcon } from "expo-dynamic-app-icon";
import { useTheme } from "@react-navigation/native";


const IconSwitcher = ({ icon, onPress }) => {
  const activeIcon = getAppIcon();

  console.log("activeIcon", activeIcon)

  const isActive = activeIcon === icon.name;
  const theme = useTheme();

  return (
    <View
      style={{
        borderWidth: isActive ? 2 : 0,
        padding: 5,
        alignItems: "center",
        justifyContent: "center",
      }}
    >
      <TouchableOpacity
        onPress={() => {
          Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Heavy);

          console.log("icon.name", icon.name)
          const result = setAppIcon(icon.name);

          console.log('result', result)
          //returns "gorg" or "little-gorg" respectively

          onPress();
        }}
      >
        <Image
          source={icon.image}
          style={{ height: 75, aspectRatio: 1, borderRadius: 20 }}
        />
      </TouchableOpacity>
    </View>
  );
};

export default IconSwitcher;

Even if I get the returned icon name when calling setAppIcon (as if it succeeded), it does not update the app icon, even if I reload the app.

When I run, I get "DEFAULT". It seems like it isn't changing it at all. I have double-checked that the images are at the correct path.

const activeIcon = getAppIcon();

console.log("activeIcon", activeIcon)

// returns "DEFAULT"
@BR19-gh
Copy link

BR19-gh commented Jul 29, 2024

Did you rebuild the app? It needs to be built again for the changes in app.json to take affect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants