我的应用未显示在iOS通知中心 - Appcelerator

时间:2017-01-19 03:02:47

标签: ios xcode apple-push-notifications titanium appcelerator

我在使用钛金属加速器推动iOS时遇到了严重的麻烦。

我在testflight中生成了多个版本,但没有一个版本出现在iOS通知中心,但是,当我直接滑入设备时,它在我的iPad Mini上正常工作。

我目前正在使用这些设置:

Operating System
  Name                        = Mac OS X
  Version                     = 10.12

  Architecture                = 64bit
  # CPUs                      = 4
  Memory                      = 4294967296

Node.js
  Node.js Version             = 4.6.0
  npm Version                 = 2.15.9

Titanium CLI
  CLI Version                 = 5.0.9

Titanium SDK
  SDK Version                 = 5.5.1.GA
  SDK Path                    = /Users/silvio/Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA
  Target Platform             = iphone

Xcode版本:8.2(8C38)

我在Alloy.js中的代码:

if (Ti.Platform.name === 'android') {
  // set android-only options
  var pnOptions = {
    senderId: 'xxxx', // It's the same as your project id
    notificationSettings: {
      sound: 'mysound.mp3', // Place soudn file in platform/android/res/raw/mysound.mp3
      smallIcon: 'appicon.png', // Place icon in platform/android/res/drawable/notification_icon.png
      largeIcon: 'appicon.png', // Same
      vibrate: true, // Whether the phone should vibrate
      insistent: true, // Whether the notification should be insistent
      group: 'Edufy', // Name of group to group similar notifications together
      localOnly: false, // Whether this notification should be bridged to other devices
      priority: 2 // Notification priority, from -2 to 2
    }
  };

} else { // set ios-only options.
  // Sets interactive notifications as well if iOS8 and above. Interactive notifications is optional.
  if (parseInt(Ti.Platform.version.split(".")[0], 10) >= 8) {
    var thumbUpAction = Ti.App.iOS.createUserNotificationAction({
      identifier: "THUMBUP_IDENTIFIER",
      title: "Aceitar",
      activationMode: Ti.App.iOS.USER_NOTIFICATION_ACTIVATION_MODE_BACKGROUND,
      destructive: false,
      authenticationRequired: false
    });

    var thumbDownAction = Ti.App.iOS.createUserNotificationAction({
      identifier: "THUMBDOWN_IDENTIFIER",
      title: "Regeitar",
      activationMode: Ti.App.iOS.USER_NOTIFICATION_ACTIVATION_MODE_BACKGROUND,
      destructive: false,
      authenticationRequired: false
    });

    var thumbUpDownCategory = Ti.App.iOS.createUserNotificationCategory({
      identifier: "THUMBUPDOWN_CATEGORY",
      // The following actions will be displayed for an alert dialog
      actionsForDefaultContext: [thumbUpAction, thumbDownAction],
      // The following actions will be displayed for all other notifications
      actionsForMinimalContext: [thumbUpAction, thumbDownAction]
    });

    var pnOptions = {
      types: [Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT, Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND],
      categories: [thumbUpDownCategory]
    };
  } else { //No support for interactive notifications, omit categories
    var pnOptions = {
      types: [Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT, Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND]
    };
  }
}

// set cross-platform event
var onReceive = function(event) {};

// Create instance with base url
var tiPush = require('ti-push-notification').init({
  backendUrl: "http://xxxx.com.br/painel/ws/push_test.php"
});

// register this device
tiPush.registerDevice({
  pnOptions: pnOptions,
  onReceive: onReceive,
  extraOptions: {
    action: 'register',
    user_id: 123
  }
});

我在Apple商店的证书都有效,如下面的图片所示:

推送通知已启用:

enter image description here

证书:

enter image description here

Prov Profiles:

enter image description here

另外,我尝试在这些位置添加Entitlements.plist:

  • Project / Entitlements.plist
  • Project / app / Entitlements.plist
  • Project / app / platform / ios / Entitlements.plist
  • 项目/ app / platform / ios / .plist

我还将标签内的行添加到tiapp.xml中,但它无效...在Entitlements.plist代码下面:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>aps-environment</key>
    <string>development</string> <!-- Either development or production -->
    <key>application-identifier</key>
    <string>xxxx.com.colegiokennedy</string>
    <key>keychain-access-groups</key>
    <array>
      <string>xxx.com.colegiokennedy</string>
    </array>
</dict>
</plist>

我也尝试将开发环境改为生产环境,但它也没有用。

1 个答案:

答案 0 :(得分:0)

您可以尝试包含 Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE

确保在iOS设备中转到设置 - &gt;通知 - &gt; Your_App - &gt;已选择在通知中心中显示。您可以检查应用通知的开/关设置类型。