Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom PUSH notifications sound in iOS??? #6697

Closed
Syirrus opened this issue Apr 15, 2017 · 3 comments
Closed

Custom PUSH notifications sound in iOS??? #6697

Syirrus opened this issue Apr 15, 2017 · 3 comments

Comments

@Syirrus
Copy link

Syirrus commented Apr 15, 2017

Rocket.Chat Version: 0.55.0
Running Instances: 1
DB Replicaset OpLog: None
Node Version: Latest

Does anyone know how to get custom sound notifications to play on iOS? I have it working in Android by changing the name of my sound file to "chime" and placing it in the appropriate directory on my Cordova build. I think the problem with it not working (push notifications do work with default sound) the file name needs to be explicitly named. "chime.mp3". I've been looking at the PushNotification.js class in particular the method: send();

	send({ roomName, roomId, username, message, usersTo, payload }) {
		let title;
		if (roomName && roomName !== '') {
			title = `${ roomName }`;
			message = `${ username }: ${ message }`;
		} else {
			title = `${ username }`;
		}
		const icon = RocketChat.settings.get('Assets_favicon_192').url || RocketChat.settings.get('Assets_favicon_192').defaultUrl;
		const config = {
			from: 'push',
			badge: 1,
			sound: 'chime',
			title: title,
			text: message,
			payload,
			query: usersTo,
			notId: this.getNotificationId(roomId),
			gcm: {
				style: 'inbox',
				summaryText: '%n% new messages',
				image: RocketChat.getURL(icon, { full: true })
			},
			apn: {
				text: title + ((title !== '' && message !== '') ? '\n' : '') + message
			}
		};

		return Push.send(config);
	}

If the file needs to be explicitly named for iOS to recognize, how could we determine if the the client is an iOS device or Android to adjust the name of the file accordingly?

Also:
Does the (apn:{} object) in Rocket.Chat object pertain to APPLE'S (aps:{} object)?

@rafaelks
Copy link
Contributor

@Syirrus Just to be sure, are you talking about the Cordova app, or the native iOS app? If you have questions about how to send the sound on the push body data, here's how to do it: http://stackoverflow.com/a/37536705/1088230.

@Syirrus
Copy link
Author

Syirrus commented Apr 18, 2017

@rafaelks Thanks for responding. I have followed this on stackoverflow before. I think the issue is this:

For Android you specify the sound payload, without the file extension i.e.: sound: 'chime'.
For iOS you specify the sound payload with the file extension i.e. sound: 'chime.wav'.

Since in pushNotification.js it's defined as 'chime' it works and in android and NOT iOS. Conversely if you change it to be 'chime.wav', it will work on iOS and not Android.

@rafaelks
Copy link
Contributor

@Syirrus OK, so it seems to be an issue on the back-end, not on the iOS app. Can you open the issue in the main project? https://github.com/RocketChat/Rocket.Chat/issues

I'll close the issue, you can open another one again if you need.

Thanks for your report! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants