outsung / expo-dynamic-app-icon

🤖 Programmatically change the app icon in Expo.
106 stars 23 forks source link

Not changing Icon #19

Open coderpr0grammer opened 7 months ago

coderpr0grammer commented 7 months ago

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 commented 3 months ago

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