Skip to content

Commit f26bc67

Browse files
authored
Update README.md
1 parent a92fc65 commit f26bc67

File tree

1 file changed

+84
-2
lines changed

1 file changed

+84
-2
lines changed

README.md

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,77 @@ npm install react-native-azurenotificationhub
8282

8383
### Export React Native Module from app
8484

85-
Coming soon.
85+
In `android/settings.gradle`
86+
87+
```gradle
88+
...
89+
90+
include ':react-native-azurenotificationhub'
91+
project(':react-native-azurenotificationhub').projectDir = file('../node_modules/react-native-azurenotificationhub/android')
92+
```
93+
94+
In `android/app/build.gradle`
95+
96+
```gradle
97+
...
98+
dependencies {
99+
...
100+
101+
compile project(':react-native-azurenotificationhub')
102+
compile 'com.google.android.gms:play-services-gcm:9.4.0'
103+
compile 'com.google.firebase:firebase-messaging:9.4.0'
104+
}
105+
```
106+
107+
In `android/app/src/main/AndroidManifest.xml`
108+
109+
```xml
110+
...
111+
112+
<uses-permission android:name="android.permission.INTERNET"/>
113+
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
114+
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
115+
116+
<application ...>
117+
...
118+
<service
119+
android:name="com.azure.reactnative.notificationhub.ReactNativeRegistrationIntentService"
120+
android:exported="false">
121+
</service>
122+
<receiver android:name="com.microsoft.windowsazure.notifications.NotificationsBroadcastReceiver"
123+
android:permission="com.google.android.c2dm.permission.SEND">
124+
<intent-filter>
125+
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
126+
</intent-filter>
127+
</receiver>
128+
...
129+
```
130+
131+
Register the module package in `MainApplication.java`
132+
133+
```java
134+
import com.azure.reactnative.notificationhub.ReactNativeNotificationHubPackage;
135+
136+
public class MainApplication extends Application implements ReactApplication {
137+
138+
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
139+
@Override
140+
protected boolean getUseDeveloperSupport() {
141+
return BuildConfig.DEBUG;
142+
}
143+
144+
@Override
145+
protected List<ReactPackage> getPackages() {
146+
return Arrays.<ReactPackage>asList(
147+
new MainReactPackage(),
148+
new ReactNativeNotificationHubPackage() // <-- Add this package
149+
);
150+
}
151+
};
152+
153+
...
154+
}
155+
```
86156

87157
## Windows Installation
88158

@@ -123,17 +193,29 @@ Coming soon.
123193
* In **MainPage.cs** of your Windows Store app, add the the `ReactAzureNotificationHubPacakge` to your configured set of packages:
124194

125195
```c#
196+
using ReactWindowsAzureNotificationHub;
197+
198+
namespace ...
199+
{
200+
public class MainPage : ReactPage
201+
{
202+
...
203+
126204
public override List<IReactPackage> Packages
127205
{
128206
get
129207
{
130208
new List<IReactPackage>
131209
{
132210
new MainReactPackage(),
133-
new ReactAzureNotificationHubPackage(), // Also add using ReactWindowsAzureNotificationHub;
211+
new ReactAzureNotificationHubPackage(), // <-- Add this package
134212
}
135213
}
136214
}
215+
216+
...
217+
}
218+
}
137219
```
138220

139221
* At this point you can register and unregister from the Azure Notification Hub instance using JavaScript as in the following example:

0 commit comments

Comments
 (0)