Local Notifications problem in iOS

I’ve made a project with the code of this example: https://www.fusetools.com/docs/fuse/localnotifications/localnotify. But in iOS when I click on sendNow button, no notificaction appears. Just if I click sendLater button and I click home button (then the app is in background).

Is there a way to make the notification appear while the app is open in the background?

In Android everything works well.

I’m using Fuse 0.35.0 in macOS Sierra. To test iOS app I use iPhone 7 and 6S simulator in XCode.

This is expected. if your app is in the foreground the notification delivers to the app itself, you will need to make the visual notification yourself.

More Info: https://www.fusetools.com/docs/fuse/localnotifications/localnotify#lifecyle-behavior

Hello Sergio,

had you problems while building the ios preview?

I use Mac OS El Capitan and i get an Fatal Error with Fuse 0.35.0.

https://www.fusetools.com/community/forums/bug_reports/fatal_error_while_building_ios_preview_on_mac

Luis Rodriguez wrote:

This is expected. if your app is in the foreground the notification delivers to the app itself, you will need to make the visual notification yourself.

More Info: https://www.fusetools.com/docs/fuse/localnotifications/localnotify#lifecyle-behavior

Thank you for your answer. How could I make that visual notification? Is there an example?

scotty2nd@gmail.com wrote:

Hello Sergio,

had you problems while building the ios preview?

I use Mac OS El Capitan and i get an Fatal Error with Fuse 0.35.0.

https://www.fusetools.com/community/forums/bug_reports/fatal_error_while_building_ios_preview_on_mac

No, it’s a problem while I’m simulating the app in iOS Simulator.

Try this Sergio, it’s ugly but it works :slight_smile:

<App Background="#eee">
    <JavaScript>
		var LocalNotify = require("FuseJS/LocalNotifications");
		var Observable =require("FuseJS/Observable");
		var thePayload = Observable();
		var visible = Observable(false);

		LocalNotify.on("receivedMessage", function(payload) {
			console.log("Received Local Notification: " + payload);
			thePayload.value = payload;
			visible.value = true;
			LocalNotify.clearAllNotifications();
		});

		function sendNow() {
			LocalNotify.now("Boom!", "Just like that", "payload", true);
		}
		module.exports = {sendNow,visible,thePayload}
    </JavaScript>
    <ClientPanel>
		<Rectangle Alignment="Center" Color="Purple" Width="100%" Height="80" Clicked="{sendNow}">
			<Text Alignment="Center" Value="Notify Me" Color="White" />
		</Rectangle>

		<Rectangle Alignment="Top" Color="#ccc" Width="100%" Height="100" Offset="0,-100%" ux:Name="Notification">
			<Text Alignment="Center" Value="{thePayload}" />
		</Rectangle>
		<WhileTrue ux:Name="showNotification" Value="{visible}">
			<Change Notification.Offset="0,0" Easing="CubicInOut" Duration=".3" DurationBack=".3" DelayBack="3"/>
		</WhileTrue>
    </ClientPanel>
</App>