Ionic v1自动开启推送通知功能

时间:2018-01-02 16:48:06

标签: cordova ionic-framework push-notification cordova-plugins

我有一个脚本可以将应用程序直接上传到AppStore。问题是推送通知功能没有自动打开。

我正在使用: cli包:(/ usr / local / lib / node_modules)

export const objectChanges = functions
  .firestore
  .document('objects/{id}')
  .onWrite(event => {
    const patch: {created_at?: string, updated_at: string} = {
      updated_at: <string> event.timestamp
    };

    if (!event.data.previous) {
      patch.created_at = event.timestamp;
    }

    return event.data.ref.set(patch, {merge: true});
  });

全球套餐:

@ionic/cli-utils  : 1.19.0
ionic (Ionic CLI) : 3.19.0

本地包裹:

cordova (Cordova CLI) : 7.0.1

系统:

Cordova Platforms : ios 4.4.0
Ionic Framework   : ionic1 1.3.1

和phonegap-plugin-push 1.10.5插件。

关于如何自动启用此功能的任何想法?

提前致谢!

1 个答案:

答案 0 :(得分:0)

如果您使用Fastlane进行交付,可以在Fastfile中使用它:

sh "fastlane produce enable_services --push-notification"

否则

我在项目中使用了这个Ruby脚本。也许它对你有帮助。 请记住重命名“name”变量 https://gist.github.com/aitoraznar/87e2c3b458b2d799ae049be5e84d578d

#!/usr/bin/env ruby
require 'xcodeproj'

name = "app_name" // <-Replace with your app name
projectpath = "platforms/ios/" + name + ".xcodeproj"
puts "Adding entitlement push to " + name
puts "Opening " + projectpath
proj = Xcodeproj::Project.open(projectpath)
entitlement_path = name + "/" + name + ".entitlements"

group_name= proj.root_object.main_group.name

file = proj.new_file(entitlement_path)

attributes = {}
proj.targets.each do |target|
    attributes[target.uuid] = {"SystemCapabilities" => {"com.apple.Push" => {"enabled" => 1}}}
    #target.add_file_references([file])
    puts "Added to target: " + target.uuid
end
proj.root_object.attributes['TargetAttributes'] = attributes

proj.build_configurations.each do |config|
    config.build_settings.store("CODE_SIGN_ENTITLEMENTS", entitlement_path)
end
puts "Added entitlements file path: " + entitlement_path

#proj.recreate_user_schemes
proj.save