iOS Question Custom notifications sound problem on reinstall

vikingivesterled

Active Member
Licensed User
Longtime User
Creating an app that plays small soundbits occasionally and to make it work in the background I schedule them as notifications using the Application_Background event, since background Audio dies if the audio is not playing constantly.
This works fine on a first install, playing the soundfiles from the special folder with the motifications,
but when I reinstall(upgrade) the app, new notifications revert to the default notification sound.
To bring back the custom sounds I have to uninstall the application and then reinstall it.

I install/reinstall using the b4i-bridge and Tools - Build Server - Build Release App
Then when it first opens I have to Accept the Notification permissions.
(The last part is not repeated on reinstall, but the permissions are still on the phone)
I have tried putting the line
App.RegisterUserNotifications(True, True, True)
several more places in the app, but it makes no difference.

It makes no difference wether I reinstall with app in background mode,
or wether I kill the app by the "double home tap and swipe the app up" sequenze before reinstalling.

This behaviour is very impractical since I loose all the local stored data if uninstalling,
and there is a lot of reinstalls(upgrades) when developing,
and customers could get it if they later upgrade to a newer version.
All the installs/reinstalls has the same #Version number, but changing it makes no difference.
 

vikingivesterled

Active Member
Licensed User
Longtime User
Hi,

before registering a new Notification call App.ClearLocalNotifications.

Jan

I'm already calling App.ClearLocalNotifications in the subs:
Application_Start
Application_Active
Application_Foreground

But I can't call it before registering every notification because I schedule 100 of them
through Application_Background
to get a constant sounding alarm at a set time when in background mode.
 
Upvote 0

vikingivesterled

Active Member
Licensed User
Longtime User
Ok,

be sure you are setting the soundName before calling the Register method.

Jan

I use the:
B4X:
Dim snln As Notification
snln.Initialize(NotTimeCorrected)
Dim snno As NativeObject = snln
snln.AlertBody = NotBody
snln.PlaySound = True
snno.SetField("soundName", "mabell1.wav")
snln.Register

The wav files are no more than 10sec long so are not hitting the 30sec limit.

The custom notification sound is working perfectly on a first install of the app.
It's when I install it again it reverts to the standard notification sound.
And it is like that until I completely uninstall and then reinstall the app again.

Wonder if it's a bug in that there is a slight change in the background compilation when an app is reinstalled, and that the ios don't fully connect the permissions you accept on the opening of the app after a first install, to the reinstall/upgrade.


I have sent the app in to Apple to see what they say, since it's find on a first install.
But I fear they'll get stuck on the ipv6 issue with iHttp, again.
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Please use [code]code here...[/code] tags when posting code.
But I fear they'll get stuck on the ipv6 issue with iHttp, again.
???

The issue is not related to permissions as the notifications play.
You don't need to call ClearLocalNotifications multiple time. You need to call it once and then add all the notifications.
 
Upvote 0

vikingivesterled

Active Member
Licensed User
Longtime User
Please use [code]code here...[/code] tags when posting code.

???

The issue is not related to permissions as the notifications play.
You don't need to call ClearLocalNotifications multiple time. You need to call it once and then add all the notifications.

I'm just adding it to ensure notifications are cancelled every time the app is started or comes to the foreground,
because then the sound functionality is handled by a MediaPlayer.
I add the notifications when it goes to the background.

However it don't change the main problem:
Custom sounds is not working if the app is reinstalled over an existing install, without first uninstalling the previous install.
They revert instead to the standard Notification sound.
I don't know yet if this only happens if reinstalled using b4i and won't happen if upgraded through the AppStore.
 
Upvote 0

vikingivesterled

Active Member
Licensed User
Longtime User
The behavior will probably be the same.
Looks like a bug in iOS: https://forums.developer.apple.com/thread/63186

Thank's Erel
Noted a comment in the article about it being fixed in 10.1.0 something beta
Updated the iPhone today to 10.1.1 - installed the app twice - and the bug seems to have gone.
Must be very recent because I upgraded it also last week when I first discovered the problem.

However fyi I did discover a new issue with this iPhone update:
A lot of the apps, including the B4i-bridge got a white warning label on them when first opened
saying something like: This App might slow your device down since the developer hasn't upgraded it
Including 2 apps I have been compiling yesterday and today.
It's only on first open, can't reproduce it now.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
A lot of the apps, including the B4i-bridge got a white warning label on them when first opened
saying something like: This App might slow your device down since the developer hasn't upgraded it
This warning will not show in release applications. Only for debug builds (where the build server settings are set to 32 bit).
 
Upvote 0
Top