Customizing Appcelerator Titanium Module

How to customize Pushwoosh SDK for your Appcelerator Titanium project

Push Notifications in Foreground

By default, Pushwoosh plugin does not display notifications in the foreground and automatically triggers onPushOpened callback. This is controlled by PW_BROADCAST_PUSHmetadata on Android:

tiapp.xml
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
  <android xmlns:android="http://schemas.android.com/apk/res/android">
    <manifest>
      <application>
        <!-- Set to false if you want to disable automatic push open in foreground -->
        <meta-data android:name="PW_BROADCAST_PUSH" android:value="true"/>
      </application>
    </manifest>
  </android>
</ti:app>

And Pushwoosh_ALERT_TYPE Info.plist key on iOS:

tiapp.xml
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
  <ios>
    <plist>
      <dict>
        <!-- Set value to ALERT or BANNER to change notification appearance in foreground -->
        <key>Pushwoosh_ALERT_TYPE</key>
        <string>NONE</string>
      </dict>
    </plist>
  </ios>
</ti:app>

Custom Push Sound

To enable custom push notifications sounds for Android put sound samples in app/platform/android/res/raw folder. The sounds will be accessible through Sound dropdown menu of Send Push panel.

Custom Push Icon

Push notification icon can be customized on Android locally by using pw_notification as resource name for such icon; or remotely by referencing any resource name in Icon setting in Send Push panel. Android resources should be placed in app/platform/android/res/ folder

Custom Push Data

Custom push data can be sent using Action setting in the Send Push panel. To receive and handle such data use the following code:

pushwoosh.onPushOpened(function(e) {
	var customData = e.extras;
  // handle custom push data
});

Push receive callback

If application is registered for push notifications and is not closed, push delivery event can be handled using:

pushwoosh.onPushReceived(function(e) {
	var message = e.message;
  var foreground = e.foreground;
  var customData = e.extras;
  var raw = e.data;
  
  // handle push receive here
});

For iOS, enable Background Modes:

tiapp.xml
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
  <ios>
    <plist>
      <dict>
        <key>UIBackgroundModes</key>
        <array>
          <string>remote-notification</string>
        </array>
			</dict>
    </plist>
  </ios>
</ti:app>

iOS10+ Media attachment

You need to add Notification Service Extension to the XCode project. The problem is that Titanium does not expose access to the XCode project and builds it in the background. See this thread for the possible solution: https://github.com/Pushwoosh/pushwoosh-appcelerator-titanium/issues/45

Share your feedback with us

Your feedback helps us create a better experience, so we would love to hear from you if you have any issues during the SDK integration process. If you face any difficulties, please do not hesitate to share your thoughts with us via this form.

Last updated