@@ -203,6 +203,9 @@ const channelImportance = 3; // The channel's importance (NotificationM
203203const channelShowBadge = true ;
204204const channelEnableLights = true ;
205205const channelEnableVibration = true ;
206+ const template = ' ...' ; // Notification hub templates:
207+ // https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-templates-cross-platform-push-messages
208+ const templateName = ' ...' ; // The template's name
206209
207210export default class App extends Component {
208211 constructor (props ) {
@@ -213,7 +216,7 @@ export default class App extends Component {
213216 register () {
214217 PushNotificationEmitter .addListener (EVENT_AZURE_NOTIFICATION_HUB_REGISTERED , this ._onAzureNotificationHubRegistered );
215218 PushNotificationEmitter .addListener (EVENT_AZURE_NOTIFICATION_HUB_REGISTERED_ERROR , this ._onAzureNotificationHubRegisteredError );
216-
219+
217220 NotificationHub .register ({
218221 connectionString,
219222 hubName,
@@ -225,12 +228,59 @@ export default class App extends Component {
225228 channelEnableLights,
226229 channelEnableVibration
227230 })
231+ .then ((res ) => console .warn (res))
232+ .catch (reason => console .warn (reason));
233+ }
234+
235+ registerTemplate () {
236+ PushNotificationEmitter .addListener (EVENT_AZURE_NOTIFICATION_HUB_REGISTERED , this ._onAzureNotificationHubRegistered );
237+ PushNotificationEmitter .addListener (EVENT_AZURE_NOTIFICATION_HUB_REGISTERED_ERROR , this ._onAzureNotificationHubRegisteredError );
238+
239+ NotificationHub .registerTemplate ({
240+ connectionString,
241+ hubName,
242+ senderID,
243+ template,
244+ templateName,
245+ tags,
246+ channelName,
247+ channelImportance,
248+ channelShowBadge,
249+ channelEnableLights,
250+ channelEnableVibration
251+ })
252+ .then ((res ) => console .warn (res))
253+ .catch (reason => console .warn (reason));
254+ }
255+
256+ getInitialNotification () {
257+ NotificationHub .getInitialNotification ()
258+ .then ((res ) => console .warn (res))
259+ .catch (reason => console .warn (reason));
260+ }
261+
262+ getUUID () {
263+ NotificationHub .getUUID (false )
264+ .then ((res ) => console .warn (res))
265+ .catch (reason => console .warn (reason));
266+ }
267+
268+ isNotificationEnabledOnOSLevel () {
269+ NotificationHub .isNotificationEnabledOnOSLevel ()
270+ .then ((res ) => console .warn (res))
228271 .catch (reason => console .warn (reason));
229272 }
230273
231274 unregister () {
232275 NotificationHub .unregister ()
233- .catch (reason => console .warn (reason));
276+ .then ((res ) => console .warn (res))
277+ .catch (reason => console .warn (reason));
278+ }
279+
280+ unregisterTemplate () {
281+ NotificationHub .unregisterTemplate (templateName)
282+ .then ((res ) => console .warn (res))
283+ .catch (reason => console .warn (reason));
234284 }
235285
236286 render () {
@@ -240,28 +290,63 @@ export default class App extends Component {
240290 < View style= {styles .button }>
241291 < Text style= {styles .buttonText }>
242292 Register
243- < / Text >
293+ < / Text >
294+ < / View>
295+ < / TouchableOpacity>
296+ < TouchableOpacity onPress= {this .registerTemplate .bind (this )}>
297+ < View style= {styles .button }>
298+ < Text style= {styles .buttonText }>
299+ Register Template
300+ < / Text >
301+ < / View>
302+ < / TouchableOpacity>
303+ < TouchableOpacity onPress= {this .getInitialNotification .bind (this )}>
304+ < View style= {styles .button }>
305+ < Text style= {styles .buttonText }>
306+ Get initial notification
307+ < / Text >
308+ < / View>
309+ < / TouchableOpacity>
310+ < TouchableOpacity onPress= {this .getUUID .bind (this )}>
311+ < View style= {styles .button }>
312+ < Text style= {styles .buttonText }>
313+ Get UUID
314+ < / Text >
315+ < / View>
316+ < / TouchableOpacity>
317+ < TouchableOpacity onPress= {this .isNotificationEnabledOnOSLevel .bind (this )}>
318+ < View style= {styles .button }>
319+ < Text style= {styles .buttonText }>
320+ Check if notification is enabled
321+ < / Text >
244322 < / View>
245323 < / TouchableOpacity>
246324 < TouchableOpacity onPress= {this .unregister .bind (this )}>
247325 < View style= {styles .button }>
248326 < Text style= {styles .buttonText }>
249327 Unregister
250- < / Text >
328+ < / Text >
329+ < / View>
330+ < / TouchableOpacity>
331+ < TouchableOpacity onPress= {this .unregisterTemplate .bind (this )}>
332+ < View style= {styles .button }>
333+ < Text style= {styles .buttonText }>
334+ Unregister Template
335+ < / Text >
251336 < / View>
252337 < / TouchableOpacity>
253338 < / View>
254339 );
255340 }
256-
341+
257342 _onAzureNotificationHubRegistered (registrationID ) {
258343 console .warn (' RegistrationID: ' + registrationID);
259344 }
260-
345+
261346 _onAzureNotificationHubRegisteredError (error ) {
262347 console .warn (' Error: ' + error);
263348 }
264-
349+
265350 _onRemoteNotification (notification ) {
266351 console .warn (notification);
267352 }
0 commit comments