bndkt / react-native-widget-extension Goto Github PK
View Code? Open in Web Editor NEWAdd widgets and live activities to a React Native app
Home Page: https://bndkt.com/blog/2023/ios-live-activities
Add widgets and live activities to a React Native app
Home Page: https://bndkt.com/blog/2023/ios-live-activities
Could we have a more minimal example, everything I tried to remove from the current example broke it.
I am not sure what can and cannot be removed.
I only use it for a simple widget, so no data is passed from rn and it is completely static.
Not sure what went wrong here...
In text:
› Copying ios/BeaconHangOutMore/GoogleService-Info.plist ➜ ./GoogleService-Info.plist
› Copying ios/BeaconHangOutMore/Supporting/Expo.plist ➜ ./Expo.plist
› Compiling BeaconHangOutMore » SplashScreen.storyboard
› Preparing BeaconHangOutMore » Info.plist
❌ (ios/Pods/Target Support Files/Pods-BeaconHangOutMore/ExpoModulesProvider.swift:19:8)
17 | import ExpoLinearGradient
18 | import ExpoSMS
> 19 | import ReactNativeWidgetExtension
| ^ no such module 'ReactNativeWidgetExtension'
20 | #if EXPO_CONFIGURATION_DEBUG
21 | import EXDevLauncher
22 | import EXDevMenu
▸ ** ARCHIVE FAILED **
▸ The following build commands failed:
▸ SwiftCompile normal arm64 Compiling\ ExpoModulesProvider.swift /Users/expo/workingdir/build/ios/Pods/Target\ Support\ Files/Pods-BeaconHangOutMore/ExpoModulesProvider.swift (in target 'BeaconHangOutMore' from project 'BeaconHangOutMore')
▸ SwiftCompile normal arm64 /Users/expo/workingdir/build/ios/Pods/Target\ Support\ Files/Pods-BeaconHangOutMore/ExpoModulesProvider.swift (in target 'BeaconHangOutMore' from project 'BeaconHangOutMore')
▸ (2 failures)
2023-11-21 10:28:45.570 xcodebuild[34960:43004] DVTCoreDeviceEnabledState: DVTCoreDeviceEnabledState_Disabled set via user default (DVTEnableCoreDevice=disabled)
** ARCHIVE FAILED **
The following build commands failed:
SwiftCompile normal arm64 Compiling\ ExpoModulesProvider.swift /Users/expo/workingdir/build/ios/Pods/Target\ Support\ Files/Pods-BeaconHangOutMore/ExpoModulesProvider.swift (in target 'BeaconHangOutMore' from project 'BeaconHangOutMore')
SwiftCompile normal arm64 /Users/expo/workingdir/build/ios/Pods/Target\ Support\ Files/Pods-BeaconHangOutMore/ExpoModulesProvider.swift (in target 'BeaconHangOutMore' from project 'BeaconHangOutMore')
(2 failures)
Exit status: 65
+-------------+-------------------------+
| Build environment |
+-------------+-------------------------+
| xcode_path | /Applications/Xcode.app |
| gym_version | 2.213.0 |
| sdk | iPhoneOS16.4.sdk |
+-------------+-------------------------+
Looks like fastlane ran into a build/archive error with your project
It's hard to tell what's causing the error, so we wrote some guides on how
to troubleshoot build and signing issues: https://docs.fastlane.tools/codesigning/getting-started/
Before submitting an issue on GitHub, please follow the guide above and make
sure your project is set up correctly.
fastlane uses `xcodebuild` commands to generate your binary, you can see the
the full commands printed out in yellow in the above log.
Make sure to inspect the output above, as usually you'll find more error information there
[!] Error building the application - see the log above
Error: The "Run fastlane" step failed with an unknown error. Refer to "Xcode Logs" below for additional, more detailed logs.
Hello,
I'm trying to use this module with a few requirements in mind for my project:
I was trying to change the parameters and such for the update and end activity functions, but I noticed that in the node_modules, the parameters were not correct.
I also noticed that your startActivity will take any arguments and simply pass it to the native side, but your update and end activity function have explicitly stated the parameters.
I tried to manually change the node_modules file but, once I run prebuild again, it overwrites the contents of the node_modules file anyways.
Am I doing something wrong?
Hello!! This is just a question as I didn't find the info on the readme or the blog, if I want to create more than one widget how I could make that using your plugin? No rush at all on this, is just a doubt if it's possible or if there is a plan to implement it.
The app in example/
doesn't run by default. Seems we need to run a build step first:
$ npx expo start
Error: Cannot find module './plugin/build
Is it easy to list the steps to run the example?
I'm also happy to send a PR for the readme if you can point me in the right direction.
Is there a way to modify the bundle id?
Thanks for your work!
Hi,
Thanks for the great work, when trying to build, i get this issue:
12 | import ExpoLinearGradient
13 | import ExpoSystemUI
> 14 | import ReactNativeWidgetExtension
| ^ no such module 'ReactNativeWidgetExtension'
15 |
16 | @objc(ExpoModulesProvider)
17 | public class ExpoModulesProvider: ModulesProvider {
expo app on macOS, i configured as the doc says and the widget is working in xcode,
Thanks,
Théo
is there any documentation on how to make lock screen widgets with this extension?
Hey, just found this repo, looks great and will definitely follow it!
I noticed that you support both the regular widgets and Live Activities. However, for Live Activities only iOS 16.x is supported. I was wondering, if you want to support only regular widgets, could we lower the minimum deployment version to 14.0, and just throw exceptions in the Native module if the live activities methods are being invoked on iOS <16.x?
EDIT: I see in the code that all the live activities methods are already wrapped in if available
, which means that it should work just fine if we use the minimum deployment version of 14.0?
When I follow the instructions on how to install this extension, my Expo app compiles, but I can't open it with Expo Go.
Whenever I do that (with an iPhone 14 Pro Max), I get the following errors:
Error: Cannot find native module 'ReactNativeWidgetExtension', js engine: hermes
Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes
Does anyone know how to fix that or what went wrong?
Building the app with expo-build-properties/use_frameworks enabled throws the following error:
[!] Unable to integrate the following embedded targets with their respective host targets (a host target is a "parent" target which embeds a "child" target like a framework or extension):
- App (true) and AppWidgets (false) do not both set use_frameworks!.
pod exited with non-zero code: 1
Is there any ways to enable it in the modoule?
I've just gotten started with this amazing library, however I am wondering on best possible development workflow.
Is there a way to update the Widget Swift Code without needing to create a new build after every change?
This is great for getting the live activity to show, but to use OneSignal push notifications to update this how would I go about it?
This is the code I use Natively but I can't work out how to include and init the OneSignal framework in your module?
let attributes = MatchActivityAttributes(id: fixture!.id, matchDate: matchDate, homeTeam: fixture?.home_team ?? "n/a", awayTeam: fixture?.away_team ?? "", homeLogo: homeUrl, awayLogo: awayUrl, competitionName: fixture?.competition.name ?? "n/a", competitionLogo: "")
let contentState = MatchActivityAttributes.ContentState(homeScore: "\(fixture?.home_score ?? 0)", awayScore: "\(fixture?.away_score ?? 0)", status: "\(fixture?.status ?? "")", minutes: "\(fixture?.status ?? "")")
let activity = try Activity<MatchActivityAttributes>.request(
attributes: attributes,
contentState: contentState,
pushType: .token)
Task {
self.followButton.isEnabled = false
self.followButton.backgroundColor = .systemGray
for await data in activity.pushTokenUpdates {
let myToken = data.map {String(format: "%02x", $0)}.joined()
OneSignal.enterLiveActivity("fixture_\(fixture?.id ?? 0)", withToken: myToken)
print("Activity started for fixture_\(fixture!.id)")
}
}
Hello,
I've been trying to run the example given by the package throughout the example folder as following the blog. However, I found the following problem:
"Cannot find native module 'ReactNativeWidgetExtension"
I have build the project multiple times and none of the cases the native component is found. How should I test this library properly?
Hi Guys
I'm working on integrating live activities with push notifications on my React native project, the push notification will be managed by Braze, and here is where I get some doubts on how to interact between them since I need to add this portion of code at native side at the moment where startActivity is called, but I can't find any info related and idk if it's supported by your plugin or where I can find the startActivity function on the native side as I made a find using startActivity as you have or even launchActivity.
I would like to understand a bit more about how it interacts with native code or if you have a way to do it
if let activity = try? Activity.request(attributes: activityAttributes,
content: activityContent,
// Setting your pushType as .token allows the Activity to generate push tokens for the server to watch.
pushType: .token) {
// Register your Live Activity with Braze using the pushTokenTag
AppDelegate.braze?.liveActivities.launchActivity(pushTokenTag: "live-activity-1",
activity: activity)
}
Hey! Checked the ios
folder but I don't see any swift files with a module. Just peaking at the code for now. Am I missing something?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.