gitn00b1337 / expo-widgets

Bringing widget functionality to expo!
116 stars 9 forks source link

can't get the widget working on iOs simulator or real iPhone (ios only) #23

Closed cristopher-rodrigues closed 1 week ago

cristopher-rodrigues commented 1 month ago

App.js

import { Button, Platform, StyleSheet, Text, View } from "react-native";
import * as ExpoWidgetsModule from "@bittingz/expo-widgets";
import Constants from "expo-constants";

/*
  A super simple example of using widgets

  For multiple widget support, the android setWidgetData now needs a package
  parameter passed as the second argument.

  To run this locally you can do the following in the example project folder

  > npm run prebuild:ios
  > npm run ios

  and
  > npm run prebuild:android
  > npm run android
*/
export default function App() {
  function sendWidgetData() {
    const androidPackage = Constants.expoConfig?.android?.package;

    if (Platform.OS === "ios") {
      const json = JSON.stringify({ message: "Hello from app!" });
      ExpoWidgetsModule.setWidgetData(json);
    } else if (androidPackage) {
      const json = JSON.stringify({ message: "Hello from app!" });
      ExpoWidgetsModule.setWidgetData(json, androidPackage);
    }
  }

  return (
    <View style={styles.container}>
      <Text>Example App!</Text>
      <Button title="Send Widget Data!" onPress={sendWidgetData} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
  },
});

app.json

{
  "expo": {
    "name": "monex",
    "slug": "monex",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "userInterfaceStyle": "light",
    "owner": "cristopher.rodrigues",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "com.cristopher.rodrigues.monex"
    },
    "plugins": [
      [
        "@bittingz/expo-widgets",
        {
          "ios": {
            "src": "./widgets/ios",
            "mode": "development",
            "devTeamId": "HFL565H8UD",
            "entitlements": {
              "com.apple.security.application-groups": [
                "group.com.cristopher.rodrigues.monex.expowidgets"
              ]
            },
            "moduleDependencies": [
              "MyData.swift",
              "LogHandler.swift"
            ]
          },
          "android": {
            "src": "./widgets/android",
            "widgets": [
              {
                "name": "SampleWidget",
                "resourceName": "@xml/sample_widget_info"
              }
            ]
          }
        }
      ]
    ],
    "extra": {
      "projectId": "my-project",
      "eas": {
        "projectId": "my-project"
      }
    }
  }
}

image

gitn00b1337 commented 1 month ago

Please run the example project. If there's an issue with ios 18 then I'll take a look. If not, it's something wrong in your widget and you should be able to figure it out by adjusting one feature at a time.

Isn't iOS 18 still a beta release (3?).

gitn00b1337 commented 1 week ago

No further input provided, closing this issue. Reopen if you have more information.