Push Notifications

How to enable Push Notifications.

Setup Push Notification on iOS

There are three steps to enable push notifications:

  1. Configure push notifications on Apple Developer Account.
  2. Enable push notifications in xCode.
  3. Enable push notifications in app with Marketo SDK.

Configure Push Notifications on Apple Developer Account

  1. Log into the Apple Developer Member Center.
  2. Click on “Certificates, Identifiers & Profiles”.
  3. Click on “Certificates->All” folder underneath “iOS, tvOS, watchOS”.
  4. Select the “+” on the top left screen next to certificates
  5. Enable “Apple Push Notification service SSL (Sandbox & Production)” checkbox, and click “Continue”.
  6. Select the application identifier that you are using the build the app.
  7. Create and upload CSR to generate the push certificate.
  8. Download certificate to local computer and double-click to install.
  9. Open “Keychain Access”, right click on the certificate, and export 2 items into .p12 file.key_chain
  10. Upload this file through Marketo Admin Console to configure notifications.Screen Shot 2015-03-13 at 2.58.03 PM
  11. Update app provisioning profiles.

Enable Push Notifications in xCode

  1. Turn on push notification capability in xCode project.

Enable Push Notifications in App with Marketo SDK

Add the following code to AppDelegate.m file to deliver push notifications to your customer’s devices.

Note – If using Adobe Launch extension, use “ALMarketo” as classname

1. Import following in AppDelegate.h.


2. Add UNUserNotificationCenterDelegate to AppDelegate as shown below.


3. Initiate Push notification Service

To enable push notification add below code.


Call this method to initiate the registration process with Apple Push Service. If registration succeeds, the app calls your App delegate object’s application:didRegisterForRemoteNotificationsWithDeviceToken: method and passes it a device token.

If registration fails, the app calls its App delegate’s application:didFailToRegisterForRemoteNotificationsWithError: method instead.

4 Register Push Token with Marketo

To receive push notifications from Marketo you must register the device token with Marketo.


The token can also be unregistered when user logs out.


Note To re-register the push token extract the code from step 3 into an AppDelegate method and call form the ViewController login method.

5. Handle push notification

To receive push notifications from Marketo you must register the device token with Marketo.





6. Add the following method in AppDelegate

By using this method you can either present alert, sound or increase badge while the app is in foreground. You must call completionHandler of your choice in this Method.


7. Handle newly received Push notification in AppDelegate

The method will be called on the delegate when the user responded to the notification by opening the application, dismissing the notification or choosing a UNNotificationAction. The delegate must be set before the application returns from applicationDidFinishLaunching:.


8. Track push notifications

If your app is running in the background (or is not active), then the device will receive a push notification as shown below. Marketo will track when the user taps the notification.

mobile8

If the device receives a push notification it will be passed to application:didReceiveRemoteNotification: callback on your App delegate.

The following is a Marketo activity log from Marketo that shows app events, and push notification events.

.mobile9

Setup Push Notification on Android

1. Add following permission inside application tag.

Open AndroidManifest.xml and add following permissions. Your app must request the “INTERNET” and “ACCESS_NETWORK_STATE” permissions. If your app already requests these permissions, then skip this step.



2. Setting up FCM with HTTPv1 (Google has deprecated XMPP protocol on 12th June, 2023 and will be removed in June 2024) 

    • Enable MME FCM HTTPv1 in Marketo feature manager

    • Upload Service Account Json file for the app in MLM. 

    • You can download the Service Account Json file from Firebase Console. 

       
    • Wait for an hour after uploading Service Account Json file in Marketo before sending push notifications.  

Android Test Devices

1. Add Marketo Activity in manifest file inside application tag.

Register Marketo Push Service

1. To receive push notifications from Marketo, you need to add the Firebase messaging service to your AndroidManifest.xml. Add before the closing application tag.



Add Marketo SDK methods in the file MyFirebaseMessagingService as follows



Note – If using Adobe extension, add as below



NOTE: The FCM SDK automatically adds all required permissions as well as the required receiver functionality. Make sure to remove the following obsolete (and potentially harmful, as they may cause message duplication) elements from your app’s manifest if you used previous versions of SDK



2. Initialize Marketo Push
After saving the configuration above, you must initialize Marketo Push Notification. Create or open your Application class and copy/paste the code below. You can get your sender ID from the Firebase console.



Note – If using Adobe Launch Extension, use these instructions



If you do not have a SENDER_ID, then enable Google Cloud Messaging Service by completing the steps detailed in this tutorial.

The token can also be unregistered when user logs out.



Note – If using Adobe Launch extension, use the instruction below



Note: To re-register the push token extract the code from step 3 into an AppDelegate method and call form the ViewController login method.

3. Set Notification Icon (Optional)
To configure a custom notification icon the following method should be called.


 

Troubleshooting

Setting up mobile push messages involves many steps and the coordination of developers and marketers. If you are experiencing difficulties, there are some simple things that you can check.

After you ensure that the simple things are correct, then you can dig deeper into the programming details.

Push Message is Not Showing Up

First, check to see if push messages are disabled on the handset. Mobile users can control whether or not they receive messages for any particular app. Often developers (and marketers) will disable these messages at some point during development. So the first thing to check is whether the recipient has disabled push messages for your app.

Second, is the app already open and active on the device? When your app is the active app on the device, mobile push messages do not pop up on the screen. Instead, they appear in the “local notifications” area of your app.

View the Activity Logs in Marketo

The first place to look when tracking down an error is in the Marketo Activity logs. You can use activity logs to verify that a message was sent.

In the activity log, look at the activity records for a person that was supposed to receive a message. If the message was sent, there will be a record present in the activity log. If not, the problem is likely due to the configuration of the iOS certificate or Android API key within Marketo.

Certificate or Key is Invalid

Double check your configuration to make sure that you have the proper certificate loaded for Sandbox or Production. Sometimes it is best to have the developer re-export the certificates (iOS) or keys (Android) and then reload them into Marketo to ensure that they are correct.

.p12 file is Missing a Certificate or Key (iOS)

When you export the certificate, make sure that you export the key and the certificate.

Provisioning Profiles Out-of-Date (iOS)

Whenever you add a new device, you need to update your provisioning profiles and generate new certificates. Make sure that your Xcode project then points to the correct profiles and certificates, and import those certificates into Marketo.

Cannot Upload iOS Certificate (IOS)

Ensure that the password used while exporting the certificate does not contain an spaces.  For example, instead of this:

“Hello World 123”

use this:

“HelloWorld123”

Troubleshooting iOS Certificates

For sandbox applications, you can use either a “developer” or “universal” certificate. But for production applications you must upload a valid “distribution” or “universal” certificate.

Push Bounce / Invalid Token

An existing registration token may cease to be valid in a number of scenarios, including:

  • If the client app unregisters with GCM.
  • If the client app is automatically unregistered, which can happen if the user uninstalls the application. For example, on iOS, if the APNS Feedback Service reported the APNS token as invalid.
  • If the registration token expires. For example, Google might decide to refresh registration tokens, or the APNS token has expired for iOS devices.
  • If the client app is updated but the new version is not configured to receive messages.