Skip to content

Commit d45ad41

Browse files
authored
Release 0.0.4 prep (#16)
* chore(docs): Update README for new Android plugin registration API * Commit from GitHub Actions (Pre-Release)
1 parent 9b7c501 commit d45ad41

File tree

2 files changed

+12
-51
lines changed

2 files changed

+12
-51
lines changed

Diff for: README.md

+11-50
Original file line numberDiff line numberDiff line change
@@ -132,63 +132,24 @@ unsubscribe('channel:topic', subscriptionReference)
132132
To see an example of Portals Pub/Sub in action that manages the lifecycle of a subscription with the lifecycle of a React Native component, refer to the [`PubSubLabel`](https://github.com/ionic-team/react-native-ionic-portals/blob/af19df0d66059d85ab8dde493504368c3bf39127/example/App.tsx#L53) implementation in the example project.
133133

134134
### Using Capacitor Plugins
135-
If you need to use any Capacitor plugins, you will have to register them in your Android project. This will also require creating and registering your Portals in native code as well:
136-
137-
**Android**
138-
```java
139-
public class MainApplication extends Application implements ReactApplication {
140-
@Override
141-
public void onCreate() {
142-
super.onCreate();
143-
144-
PortalManager.register("YOUR_PORTAL_KEY_HERE");
145-
PortalManager.newPortal("hello")
146-
.addPlugin(MyCapacitorPlugin.class) // Plugin registration
147-
.setInitialContext(Map.of("greeting", "Hello, world!"))
148-
.setStartDir("portals/hello")
149-
.create();
150-
}
151-
}
152-
```
153-
154-
**iOS**
155-
Create a Swift file for your Portals configuration:
156-
```swift
157-
import IonicPortals
158-
import ReactNativePortals
159-
160-
@objc class RNPortalsConfiguration: NSObject {
161-
@objc static func setup() {
162-
PortalManager.register("YOUR_PORTAL_KEY_HERE")
163-
164-
let portal = Portal(
165-
name: "hello",
166-
startDir: "portals/hello",
167-
initialContext: ["greeting": "Hello, world!"]
168-
)
135+
If you need to use any Capacitor plugins, the classpath of the Android plugins will have to be provided to the `Portal` `androidPlugins` property.
169136

170-
PortalManager.add(portal)
171-
}
172-
}
137+
```javascript
138+
const helloPortal = {
139+
name: 'hello',
140+
startDir: 'portals/hello',
141+
androidPlugins: ['com.capacitorjs.plugins.camera.CameraPlugin'],
142+
initialContext: {
143+
greeting: 'Hello, world!'
144+
}
145+
};
173146
```
174147

175-
Call the setup function in RNAppDelegate:
176-
```objective-c
177-
// Add the import to call the Swift code
178-
#import <YourProjectName-Swift.h>
179-
180-
@implementation RNAppDelegate
181-
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDicationary *)launchOptions {
182-
// React Native boilerplate
183-
[RNPortalsConfiguration setup];
184-
}
185-
@end
186-
```
148+
No configuration for iOS is needed since plugins are automatically registered when the Capacitor bridge initializes on iOS.
187149

188150
### Bundling Your Web Apps
189151
Currently there is no tooling for bundling your web apps directly as part of @ionic/portals-react-native. Please follow the [native guides](https://ionic.io/docs/portals/how-to/pull-in-web-bundle#setup-the-web-asset-directory) to manage this as part of the native build process.
190152

191-
192153
## Registration
193154

194155
Ionic Portals for React Native requires a key to use. Once you have integrated Portals into your project, login to your ionic account to get a key. See our doc on [how to register for free and get your Portals license key](https://ionic.io/docs/portals/how-to/get-a-product-key) and refer to the [usage](#Usage) section on how to add your key to your React Native application.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ionic/portals-react-native",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"description": "Ionic Portals for React Native",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",

0 commit comments

Comments
 (0)