Titanium JIRA Archive
Appcelerator Modules (MOD)

[MOD-2387] Android cloudpush : Custom sound is not played

GitHub Issuen/a
TypeBug
PriorityNone
StatusResolved
ResolutionFixed
Resolution Date2018-08-14T22:32:49.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterAminul Islam
AssigneeYordan Banev
Created2018-01-15T13:01:30.000+0000
Updated2018-08-14T22:32:49.000+0000

Description

Steps : 1. Create a new project and copy ti.cloud sample app
var win = Ti.UI.createWindow({
	backgroundColor : '#ccc',
	title : 'Android Cloud Push Notification'
});

var CloudPush = require('ti.cloudpush');
CloudPush.debug = true;
CloudPush.enabled = true;
CloudPush.showTrayNotificationsWhenFocused = true;
CloudPush.showTrayNotification = true;
CloudPush.focusAppOnPush = false;

var deviceToken = null;
var Cloud = require('ti.cloud');
Cloud.debug = true;

var submit = Ti.UI.createButton({
	title : 'Register For Push Notification',
	color : '#000',
	height : 60,
	width : 200,
	top : 100,
});

win.add(submit);

submit.addEventListener('click', function(e) {
	loginDefault();
});

var submit1 = Ti.UI.createButton({
	title : 'Subscribe Device',
	color : '#000',
	height : 60,
	width : 200,
	top : 200,
});

win.add(submit1);

submit1.addEventListener('click', function(e) {
	defaultSubscribe();
});

CloudPush.retrieveDeviceToken({
	success : deviceTokenSuccess,
	error : deviceTokenError
});

function deviceTokenSuccess(e) {
	deviceToken = e.deviceToken;
}

function deviceTokenError(e) {
	alert('Failed to register for push notifications! ' + e.error);
}

CloudPush.addEventListener('callback', function(evt) {
	alert("Notification received: " + evt.payload);
});

CloudPush.addEventListener('trayClickLaunchedApp', function(evt) {
	Ti.API.info('Tray Click Launched App (app was not running)');
});

CloudPush.addEventListener('trayClickFocusedApp', function(evt) {
	Ti.API.info('Tray Click Focused App (app was already running)');
});

function loginDefault(e) {
	Cloud.Users.login({
		login : 'xyz',
		password : '123456'
	}, function(e) {
		if (e.success) {
			alert("Successfully Loged In");
		} else {
			alert('Error: ' + ((e.error && e.message) || JSON.stringify(e)));
		}
	});
}

function defaultSubscribe() {
	Cloud.PushNotifications.subscribe({
		channel : 'alert',
		device_token : deviceToken,
		type : 'android'
	}, function(e) {
		if (e.success) {
			alert('Device Subscribed!');
		} else {
			alert('Error:' + ((e.error && e.message) || JSON.stringify(e)));
		}
	});
}

win.open();
2. Create the folder /Resources/sound directory. 3. Place the sound file(gsl) in the /Resources/sound directory. 4. Build your project and send custom sound from dashboard. 5. You will get default sound and get following error. 6. Custom sound not played
[INFO] :   APSCloudPush: queuePayload: {"android":{"sound":"gsl","alert":"s check ","vibrate":true},"content-available":1,"priority":"high"}
[INFO] :   APSCloudPush: showTrayNotification
[WARN] :   W/System.err: java.io.FileNotFoundException: Resources/sound/gsl
[WARN] :   W/System.err: 	at android.content.res.AssetManager.openAssetFd(Native Method)
[WARN] :   W/System.err: 	at android.content.res.AssetManager.openFd(AssetManager.java:352)
[WARN] :   W/System.err: 	at com.appcelerator.aps.APSCloudPush.getAndTransferFile(APSCloudPush.java:526)
[WARN] :   W/System.err: 	at com.appcelerator.aps.APSCloudPush.showTrayNotification(APSCloudPush.java:441)
[WARN] :   W/System.err: 	at com.appcelerator.aps.APSCloudPush.receivePayload(APSCloudPush.java:267)
[WARN] :   W/System.err: 	at com.appcelerator.aps.GCMReceiver.onReceive(GCMReceiver.java:30)
[WARN] :   W/System.err: 	at android.app.ActivityThread.handleReceiver(ActivityThread.java:2835)
[WARN] :   W/System.err: 	at android.app.ActivityThread.access$1800(ActivityThread.java:150)
[WARN] :   W/System.err: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1489)
[WARN] :   W/System.err: 	at android.os.Handler.dispatchMessage(Handler.java:102)
[WARN] :   W/System.err: 	at android.os.Looper.loop(Looper.java:168)
[WARN] :   W/System.err: 	at android.app.ActivityThread.main(ActivityThread.java:5885)
[WARN] :   W/System.err: 	at java.lang.reflect.Method.invoke(Native Method)
[WARN] :   W/System.err: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
[WARN] :   W/System.err: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
[INFO] :   APSCloudPush: getTrayPendingIntent
[INFO] :   APSCloudPush: getFocusIntent payload: {"android":{"sound":"gsl","alert":"s check ","vibrate":true},"content-available":1,"priority":"high"}
[INFO] :   APSCloudPush: processCallbackIfInstantiated payload: {"android":{"sound":"gsl","alert":"s check ","vibrate":true},"content-available":1,"priority":"high"}
[INFO] :   APSCloudPush: processQueuedCallback
Test Environment:
Operating System
  Name                        = Mac OS X
  Version                     = 10.13
  Architecture                = 64bit
  # CPUs                      = 4
  Memory                      = 8589934592
Node.js
  Node.js Version             = 8.9.1
  npm Version                 = 5.5.1
Titanium CLI
  CLI Version                 = 5.0.14
Titanium SDK
  SDK Version                 = 7.0.0.GA

Attachments

FileDateSize
gsl.wav2018-01-15T12:56:43.000+00002196

Comments

  1. Mostafizur Rahman 2018-01-24

    Hello [~ybanev], Any update on this?
  2. Yordan Banev 2018-02-01

    Module PR: https://github.com/appcelerator-modules/cloudpush/pull/37 APS PR:https://github.com/appcelerator/aps_sdk/pull/309
  3. Gary Mathews 2018-04-25

    cloudpush: https://github.com/appcelerator-modules/cloudpush/pull/40
  4. Yordan Banev 2018-06-05

  5. Michael Scholz 2018-08-06

    Any status/progress update on this issue?

JSON Source