Why Don't Push Notifications Work on iOS in All App States?

Problem

Push notifications were sent successfully from the MoEngage dashboard, but they were not delivered to the user in the foreground, background, or killed state on iOS.

Explanation

The following could be the factors for push notifications not working in all states:

  • The user is in the Test Environment, but push notifications were sent from the Live environment.
  • The user is in the Live Environment, but push notifications were sent from the Test environment.
  • User data is not being tracked to the correct profile. For example, push notifications are sent to the email xyz@mail_domain.com, but no data is tracked on the user's profile. This indicates an  issue with the SDK integration or that the user was logged out, causing a guest profile to be created.

Solution

Perform the following steps to resolve the issue:

  1. Check the user profile. Verify whether recent events are being tracked on the user profile.
    • If no recent events are found, the wrong profile may be targeted for push notifications, indicating an SDK integration issue.tracked or not.png
  2. Check SDK integration. Common SDK-related issues include:
    • The data center was incorrectly set when initializing the SDK, or the wrong data center was used.
      Inside info.plist:
      MoEngage
      
          MoEngage_APP_ID
          XXXXXXXXXXXX
          DATA_CENTER
          DATA_CENTER_0X
          ENABLE_LOGS
          
      
      Inside AppDelegate file for Obj-C and Swift both for all SDK versions:
      //7.xx
      ///Obj-C
      sdkConfig.moeDataCenter = DATA_CENTER_0X;
      
      ///Swift
      sdkConfig.moeDataCenter = DATA_CENTER_0X
      
      //7.xx Alternative
      ///Obj-C
      [MoEngage setDataCenter:DATA_CENTER_0X];
      
      ///Swift
      MoEngage.setDataCenter(DATA_CENTER_0X)
      
      //8.xx
      ///Obj-C
      sdkConfig.moeDataCenter = MODataCenterData_center_0X; 
      
      ///Swift
      sdkConfig.moeDataCenter = .data_center_0X 
      
      //9.xx
      ///Obj-C
      sdkConfig.moeDataCenter = MoEngageDataCenterData_center_0X;
      
      ///Swift
      sdkConfig.moeDataCenter = .data_center_0X
      
      //9.xx Alternative
      ///Obj-C
      MoEngageSDKConfig* sdkConfig = [[MoEngageSDKConfig alloc] initWithAppId:@"XXXXXXXXXXXXXXXX" dataCenter: MoEngageDataCenterData_center_0X];
      
      ///Swift
      var sdkConfig = MoEngageSDKConfig.init(appId: "XXXXXXXXXXXXXXXX", dataCenter: .data_center_0X)
      
    • A force logout occurred, leading to a guest profile being created, which prevents push notifications from working.force logout.png
    • A force logout can occur in the following scenarios: 
      • The developer sets a unique_id (For example, unique_id_001).
      • Without calling the MoEngage logout or reset user function, the developer sets a new unique_id (For example, unique_id_002). 

 

Was this article helpful?
0 out of 0 found this helpful

How can we improve this article?