iOS8.2 not playing custom alert sound from parse.com app - ios

I have successfully set up a push notification app via Parse.com. App is installed on iPhone 5s running iOS8.2. App code in Swift
If I send a regular push notification, it comes up fine, but plays the very short buzz (like 'quick' vibration or very short standard 'note' text alert, rather than what I have set as the standard text alert.
(If I send an iMessage, and have the alert tone set to 'chord', it plays that OK)
If I instead send the dictionary version with a custom sound included in the app bundle (yes, I converted it in terminal per Apple instructions), it still does the same as above. I cannot get it to play any custom alert sounds.
It makes no difference if I originate the push from the app, or from the button on Parse.com

Just as the other person said, ensure that your file is in the correct format (you want it in an generally .caf files)
Also, be sure that you have entered the correct file name when you are sending the push notification if you are using client push.
Example from Parse Docs:
let data = [
"alert" : "The Mets scored! The game is now tied 1-1!",
"badge" : "Increment",
"sounds" : "cheering.caf" //Ensure the file exists in your project
]
let push = PFPush()
push.setChannels(["Mets"])
push.setData(data)
push.sendPushInBackground()

Related

Activate iOS Application when remote notification with data is received

I'm creating an iOS application for two factor authentication.
I have a system where the user logs in and my server sends a challenge via remote notification (push message) to my iOS app.
I am able to receive the push notification when the app is not activated, so that's fine.
What I am not able to do is to activate my app. I don't know how to do it.
The push message contains structured data (not a simple alert text message).
Is it possible? Can I set some flag in the push message? Or is this one of those things that violates iOS guidelines?
go to App Settings -> Capabilites and turn on Background Modes for your app. Check the last option, Remote Notifications,
to know more about it check this tutorial :
This raywenderlich tutorial is all u need to get up and running with push notification
if that didn't work add : 'content_available' => true to your push notification parameters
ex :
{
"alert" :"",
"badge" :"787",
"Content-available" : "1" // or true,
"sound" : ""
}
If you provide this key with a value of 1, (if user opens you app is in background or resumed) the application:didReceiveRemoteNotification:fetchCompletionHandler: will be called.
According to RemoteNotifications Programming content-available definition is
Provide this key with a value of 1 to indicate that new content is available. Including this key and value means that when your app is launched in the background or resumed, application:didReceiveRemoteNotification:fetchCompletionHandler: is called.(Newsstand apps are guaranteed to be able to receive at least one push with this key per 24-hour window.)
You can refer to Apple Documentation about Creating the Remote Notification PayLoad and look for "Configuring a Background Update Notification". Just keep in mind this will not work if your application is force quit. Make sure your application is showing in AppSwitcher but in an inactive mode means you haven't used from a long time.

Receiving Push Notification on the Iphone

Hello I'm stuck and I need help.
I have an iOS application build with Angular2 + Cordova + cordova-firebase-plugin + xcode.
I have setup the app on developers.apple.com and firebase.console website.
Now when I try to send a Notification message, I don't receive it on Iphone at all.
If the application is runing in the foreground, I see in the debug console that the notification was received, but it is not displayed on the Iphone.
Message from console:
Received data message: {
"collapse_key" = "com.example.app"
from = 793840040300;
notification = {
body = "example test notification message";
e = 1;
}
}
What I don't see here: notification title. (The notifications are working in Android, but not in iOS).
There were no any prompts about enabling the notifications (permissions prompt).
I trieed to setup APNS-FCM connectivity via .p12 Certificates and via .p8 Certificates (via the key). Boths atemmpts did not give me positive result...
One more moment:
IF the application is running in the background - I don't see the message in the console until I will open the app. When I open the app, the message appears in the console, if it was sent while the app was in foreground..
I viewed many different guides, but I didn't get any result.
I read that emulators does not support the push notifications, so I connected a real device via USB. And it behaves the same - no push notification received - only the message in the console.
Please, help me.
Make sure you are sending both the title and body in the payload. I had the issue (in Android) that when not sending the message item, the notification would not show up in the notifications bar. The same applies for iOS, but in this case, the variables are title and body.
If the right variables are not found in the payload, both Android, iOS and Windows Phone will consider it a background notification that is silently delivered to the app (once it's opened). Notifications will not wake an unloaded app, the app is launched by the notification item once it's selected from the notifications bar in this case.
Try sending the default payload from the documentation to test it:
{
"aps": {
"alert": { // alternatively just a string: "Your Message",
"title": "A short string describing the purpose of the notification",
"body": "The text of the alert message",
// localization of message is possible
"launch-image": "The filename of an image file in the app bundle, with or without the filename extension. The image is used as the launch image when users tap the action button or move the action slider"
},
"badge": 5, // Number to show at App icon
"content-available": "0", // configure background updates, see below
"category": "identifier", // Provide this key with a string value that represents the notification’s type
"thread-id": "id", // Provide this key with a string value that represents the app-specific identifier for grouping notifications
"sound": "default" // play default sound, or custom sound, see [iOS Sound](#sound-1) section
},
"custom_key1": "value1",
"custom_key2": "value2"
}
If this doesn't work, please include the entire content of the payload you are sending to APNS, from the server side.
Edit: make sure you are sending your payload fields in UTF-8 encoding to all push services.

can we add a custom sound for notification in iOS apps, other then the default sound provided by the OS

We have a scenario where we need to play a custom notification sound for an app which is different than the notification sounds provided by OS. Is it possible can we add a different sound other than the OS sounds to the app and also do we have any problem while app review if we use such sounds in the app.
Thanks.
Yes, You can change the push notification sound.
When server sends the push notification, just add the sound file name in JSONpayload.
Sample Push Payload:
{
"aps" : {
"alert" : "Your friend needs your help.",
"sound" : "sos.wav"
}
}

Firebase push notifications custom sound

I am currently working on an app and I have implement firebase Push Notification service into my app. I am recieving notification on my iphone but I am unable to set the custom alert sound that I want.
I added the sound as a .caf
I added the sound to the Copy Bundle Resources
using print (userInfo) I have collected this data that is incomming from Firebase
aps: {
alert = {
body = MSG;
title = Title;
};
sound = default;}, {...}, sound: alarm.caf
I understand where the problem is, I just dont understand how to fix it so that the app plays my custom notification sound.
Problem with Firebase is that you can not send sound parameter like custom parameter with Firebase Console, if you try this as you do, you will get this parameter in app outside of aps Dictionary and the system will not recognize it as a sound to be played although the sound file is into the project.
The only solution for this problem is you have some API/server through which you'll be sent a Firebase notification. When server send you a notification with sound param it will be within aps Dictionary and application will play this sound when the notification arrives.
After much research I have not found any solution.
Under Firebase Messaging Docs, and
Table 2a. iOS — keys for notification messages
it is indicated that Firebase does allow for the Sound key to be included in the payload but as seen in the code printed by didRecieveRemoteNotification,
aps: {
alert = {
body = MSG;
title = Title;
};
sound = default;}, {...}, sound: alarm.caf
Firebase doesn't include the Sound key inside the aps hence not calling the sound key by the app.
The workaround that I used for my app is Easy APNs Provider which is a handy and easy app to use for development purposes, a major issue is that it doesn't have the ability to register and remove notifications automatically.
lastly: for Push Notifications to my published apps, I have opted for a dedicated server which I run off of my website
It's been over 5 years, but if someone still looking for an answer, here is what I did.
Make sure you have configured Firebase Messaging & receiving Notifications.
Add .caf ( sound file ) to the app. It must be visible on
'Target' - > 'Build Phases' & then under 'Copy Bundle Resources'
Delete the app from the device ( This is important )
I use Postman as my server, so message format would be,
{
"notification": {
"title": "Hello",
"sound":"small_message.caf",
"body": "You have a new Job"
},
"to": "your device token"
}

Push notification arguments localization

I know that it is possible to localize the message and title of a push notification, using title-loc-key, title-loc-args and loc-key, loc-args. So, that the system searches for the localized-title-formatted-string(title-loc-key) in the app bundle and substitutes the format-specifiers with title-loc-args.
My questions would be that is it possible to localize the arguments of a push notification? So that the system substitutes the format-specifiers of the formatted-string with the localized title-loc-args(arguments substituted with the localized values found in the app bundle).
For example:
Notification:
`title-loc-key`= "localization_key_shipping"
`title-loc-args`= ["localization_key_headset"]
Localization En:
"localization_key_shipping" = "Your %# is ready for shipping"
"localization_key_headset" = "headset";
Can I make this work to see "Your headset is ready for shipping" ?
Thanks for all of your advices and comments.
No, your server side code is expected to feed in localized text for arguments. See Apple docs.
Look at the Notification Service Extensions. That is how you can modify the content of a push notification before is shown to the user.
https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension
A UNNotificationServiceExtension object provides the entry point for a notification service app extension. This object lets you customize the content of a remote notification before the system delivers it to the user. A notification service app extension doesn’t present any UI of its own. Instead, it’s launched on demand when the system delivers a notification of the appropriate type to the user’s device. You use this extension to modify the notification’s content or download content related to the extension. For example, you could use the extension to decrypt an encrypted data block or to download images associated with the notification.

Resources