无法运行 bms-samples-cordova-hellopush - 找不到 bms_samples_cordova_push-Swift.h 文件

2023-11-29

我正在尝试运行可用的推送通知示例GitHub。 不幸的是,配置如概述here不起作用。

文件说: 在你的顶部AppDelegate.m:

#import "[your-project-name]-Swift.h"

如果您的项目名称包含空格或连字符,请在导入语句中将其替换为下划线。

Example:

// Project name is "Test Project" or "Test-Project"
#import "Test_Project-Swift.h"

所以我对样本做了:

#import "bms_samples_cordova_push-Swift.h"

ObjC 桥接标头设置为:

bms-samples-cordova-push/Plugins/ibm-mfp-core/Bridging-Header.h

运行路径设置为:

@executable_path/Frameworks

但是 Xcode 会抛出上面的错误。我做错了什么?


我能够得到bms-samples-cordova-hellopush使用以下步骤运行示例应用程序:

  1. 克隆样本:

    git clone https://github.com/ibm-bluemix-mobile-services/bms-samples-cordova-hellopush

  2. 添加了我的应用程序_路由 and 应用程序_GUID in my [your-directory]/www/js/index.js(在 Bluemix 上为我的 Mobile Services Starter 应用程序配置推送通知后

  3. 将 iOS 平台添加到我的应用程序中:

    cordova platform add [email protected]

  4. 添加了 Cordova 插件:

    cordova plugin add ibm-mfp-push

  5. 打开我的[your-app-name].xcodeproj文件在我的[your-app-name]/platforms/iosXcode 的目录(当提示我时:转换为最新的 Swift 语法,我点击了Cancel)

  6. 添加了桥接头。去了Build settings > Swift Compiler - Code Generation > Objective-C Bridging Header并添加以下路径:

    [your-project-name]/Plugins/ibm-mfp-core/Bridging-Header.h

bridging header

  1. 添加框架参数。去了Build Settings > Linking > Runpath Search Paths并添加了以下参数:

    @executable_path/Frameworks

executable path

  1. 建成项目

  2. 取消注释我的桥接标头中的以下 Push import 语句。去了[your-project-name]/Plugins/ibm-mfp-core/Bridging-Header.h:

bridging header

  1. 更新了我的客户端应用程序以使用 Push SDK

这是我的更新AppDelegate.m:

/*
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 */

//
//  AppDelegate.m
//  bms-samples-cordova-push
//
//  Created by ___FULLUSERNAME___ on ___DATE___.
//  Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//

#import "AppDelegate.h"
#import "MainViewController.h"
#import "bms_samples_cordova_push-Swift.h"


#import <Cordova/CDVPlugin.h>

@implementation AppDelegate

@synthesize window, viewController;

- (id)init
{
    /** If you need to do any extra app-specific initialization, you can do it here
     *  -jm
     **/
    NSHTTPCookieStorage* cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];

    [cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];

    int cacheSizeMemory = 8 * 1024 * 1024; // 8MB
    int cacheSizeDisk = 32 * 1024 * 1024; // 32MB
#if __has_feature(objc_arc)
        NSURLCache* sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"];
#else
        NSURLCache* sharedCache = [[[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"] autorelease];
#endif
    [NSURLCache setSharedURLCache:sharedCache];

    self = [super init];
    return self;
}

#pragma mark UIApplicationDelegate implementation

/**
 * This is main kick off after the app inits, the views and Settings are setup here. (preferred - iOS4 and up)
 */
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
    CGRect screenBounds = [[UIScreen mainScreen] bounds];

#if __has_feature(objc_arc)
        self.window = [[UIWindow alloc] initWithFrame:screenBounds];
#else
        self.window = [[[UIWindow alloc] initWithFrame:screenBounds] autorelease];
#endif
    self.window.autoresizesSubviews = YES;

#if __has_feature(objc_arc)
        self.viewController = [[MainViewController alloc] init];
#else
        self.viewController = [[[MainViewController alloc] init] autorelease];
#endif

    // Set your app's start page by setting the <content src='foo.html' /> tag in config.xml.
    // If necessary, uncomment the line below to override it.
    // self.viewController.startPage = @"index.html";

    // NOTE: To customize the view's frame size (which defaults to full screen), override
    // [self.viewController viewWillAppear:] in your view controller.

    [[CDVMFPPush sharedInstance] didReceiveRemoteNotificationOnLaunch:launchOptions];

    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];

    return YES;
}

// this happens while we are running ( in the background, or from within our own app )
// only valid if bms-samples-cordova-push-Info.plist specifies a protocol to handle
- (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation
{
    if (!url) {
        return NO;
    }

    // all plugins will get the notification, and their handlers will be called
    [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];

    return YES;
}

// repost all remote and local notification using the default NSNotificationCenter so multiple plugins may respond
- (void)            application:(UIApplication*)application
    didReceiveLocalNotification:(UILocalNotification*)notification
{
    // re-post ( broadcast )
    [[NSNotificationCenter defaultCenter] postNotificationName:CDVLocalNotification object:notification];
}


#if __IPHONE_OS_VERSION_MAX_ALLOWED < 90000
- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
#else
- (UIInterfaceOrientationMask)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
#endif
{
    // iPhone doesn't support upside down by default, while the iPad does.  Override to allow all orientations always, and let the root view controller decide what's allowed (the supported orientations mask gets intersected).
    NSUInteger supportedInterfaceOrientations = (1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationLandscapeLeft) | (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationPortraitUpsideDown);

    return supportedInterfaceOrientations;
}

- (void)applicationDidReceiveMemoryWarning:(UIApplication*)application
{
    [[NSURLCache sharedURLCache] removeAllCachedResponses];
}

// Register device token with Bluemix Push Notification Service
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
    
    [[CDVMFPPush sharedInstance] didRegisterForRemoteNotifications:deviceToken];
}

// Handle error when failed to register device token with APNs
- (void)application:(UIApplication*)application
didFailToRegisterForRemoteNotificationsWithError:(NSError*)error {
    
    [[CDVMFPPush sharedInstance] didFailToRegisterForRemoteNotifications:error];
}

// Handle receiving a remote notification
-(void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
    
    [[CDVMFPPush sharedInstance] didReceiveRemoteNotification:userInfo];
}

@end
  1. 在 iOS 设备上运行示例以实际注册和接收推送通知

希望我没有错过任何东西:0)

我已经联系了 Cordova 团队并提出了一些问题,以提高此示例的质量,使其更易于设置。

Edit:另外,正如下面 Sebastian 所指出的,您需要禁用位码。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

无法运行 bms-samples-cordova-hellopush - 找不到 bms_samples_cordova_push-Swift.h 文件 的相关文章

  • UIWebView 未正确加载 JavaScript - 嵌入式 Facebook 帖子

    Facebook 有一项新功能 允许用户将公共帖子嵌入网页中 我想尝试在 UIWebView 内的 iPhone 应用程序中使用它 转义必要的代码非常简单 但即使我手动转义代码 Web 视图也不会正确加载帖子 JavaScript 根本不起
  • 删除部分(红色删除按钮),UITableViewController - iOS

    我正在尝试做一个分组的 uitableview 并且我已经激活了编辑选项 我希望用户也能够删除整个部分 而不仅仅是特定行 因此 当您单击 编辑 时 每个表格单元格左侧显示的红色减号按钮也应该显示在各个部分 部分标题左侧 有人知道如何做到这一
  • 如何确定 UINavigationController 中工具栏的高度?

    我有一个带有由 UINavigationController 呈现的工具栏的视图 当我处理 UIKeyboardWillShowNotification 时 我将整个屏幕向上滚动键盘的高度 问题是当显示键盘时 底部工具栏不显示 所以我只需将
  • 使用排序函数按 NSDates 对数组进行排序[重复]

    这个问题在这里已经有答案了 我有一个名为的模型类Event import Foundation import MapKit public class Event let id Int var title String let status
  • 后台模式下的 AVSpeechSynthesizer

    我无法获取 iOS 7AVSpeechSynthesizer当我的 iOS 应用程序处于后台模式时工作 我添加了 应用程序播放音频 应用程序支持的后台模式的关键 但我仍然无法让它工作 我还研究了创建一个AVMutableCompositio
  • 当应用程序处于后台时,传递数据的 FCM Intent 在哪里?

    我已经在我的应用程序中实现了 Firebase 并且正在发送带有额外数据的推送 当我的应用程序位于前台时 我正在正确处理数据并显示我自己的通知 但是当应用程序 驻留 未终止 时 Firebase 自动 显示通知时 我在获取数据时遇到问题 根
  • 有没有办法更改 UITabBar 或 UITabBarItem 中的文本位置?

    这是我打算放在屏幕上的自定义选项卡栏 然而 我的搭档希望文字稍微向上一些 我怎样才能这样做呢 为什么不为视图控制器设置一个空的标题属性 并将标题添加到选项卡的自定义图像中 UPDATE 为了回答的完整性 来自评论和ios标签栏在没有图像时将
  • 使用服务时应用程序终止时音乐暂停

    我正在使用一个Service类在后台播放音乐 当我在顶部显示通知栏时 我的应用程序出现问题 当我终止该应用程序时 音乐停止约 1 秒 然后再次开始 我不知道出了什么问题 我正在关注this https www simplifiedcodin
  • 从 RemoteIO 录制到 AAC:数据正在写入,但文件无法播放

    我一直在尝试从 iPad 2 上的 iOS 5 中的 renderCallback 中直接从 RemoteIO 单元录制到 AAC 我看到了相互矛盾的信息 说这是不可能的 但这是可能的 在评论中 here http atastypixel
  • 有关 UnsafeMutablePointer 的 destroy() 的术语

    Destroy the object the pointer points to Precondition the memory is initialized Postcondition the value has been destroy
  • 如何更改故事板的初始视图控制器?

    我有2个视图控制器 我禁用了第一个视图控制器的初始视图控制器 并启用了第二个视图控制器 但是当启动项目时 初始视图控制器仍然是第一个视图控制器 我该怎么办 谢谢 点击第二个视图控制器 然后选择 Is initial View Control
  • 如何通过单击颤动推送通知来打开特定屏幕

    我试图在单击推送通知时打开特定屏幕 我的有效负载如下所示 var payload notification title notificationTitle body notificationMessage click action scre
  • Swift 3 中来自路径或文件名的 UIImage

    我的应用程序的文档目录中有一堆图像 我想将其中之一加载到我认为的 UIImage 中 这就是我所做的 myImage image UIImage named image jpg the file exist but this returns
  • 搜索栏与节标题视图重叠

    我将搜索栏放在 tableHeaderView 内 在 iphone 6 上一切正常 但在 iphone 5s 上我得到这个奇怪的结果 override func viewDidLoad super viewDidLoad tableVie
  • MFMailcomposeviewcontroller 发送按钮被禁用

    有没有人遇到这样的问题MFMailcomposeviewcontroller发送按钮被禁用 变灰 取消按钮工作得很好 这似乎是一个新错误 如果本机邮件应用程序从 iPhone 中删除 从 iOS 10 开始允许 则可能会发生这种情况 在这种
  • 如何确定当前处于活动状态的视图控制器/显示视图的视图控制器?

    在我的应用程序中 我正在排队一些本地通知 当它们触发时我必须呈现模式视图 问题是我有许多视图控制器 其中任何一个当前都可能处于活动状态 因此需要呈现模式视图控制器 如何确定当前正在使用哪一个 我将导航控制器设置为 Windows 根视图控制
  • 验证 iOS 应用程序时出现 com.apple.developer.linked-domains 问题

    当我在 Xcode 中使用 Organizer 验证我的项目时 出现以下错误 无效的代码签名权利 你的申请包的签名包含代码签名权利iOS 上不支持的 具体来说 值 for key com apple developer associated
  • 是否可以使用 UITableViewStylePlain 禁用 UITableView 中的浮动标题?

    我正在使用一个UITableView布局内容 页面 我使用表视图的标题来布局某些图像等 如果它们不浮动而是保持静态 就像样式设置为时那样 我更喜欢它UITableViewStyleGrouped 其他则使用UITableViewStyleG
  • Objective c,实例成员的内存管理

    我对实例成员的内存管理感到困惑 我有一个带有 ivar 的课程 DetailedResultsTableViewController detailedResultsTableViewController and property nonat
  • UITableView 干扰状态栏

    我正在开发一个具有 UITableViewController 的应用程序 该应用程序显示值列表 如下所示 如何将表格向下移动 使其不会与状态栏冲突 看来我无法对这个场景施加任何限制 所以我不知所措 使用以下 3 个属性UIViewCont

随机推荐

  • MySQL 8.0 - 客户端不支持服务器请求的身份验证协议;考虑升级MySQL客户端

    由于某种原因 我无法与服务器建立简单的连接 我使用默认设置安装了最新的 MySQL Community 8 0 数据库以及 Node JS 这是我的node js代码 var mysql require mysql var con mysq
  • 无法在页面中央显示我的导航菜单

    导航菜单未居中 我尝试了很多让它居中的方法 但没有任何效果 HTML div li a href index html Home a li li a href servicii html Servicii a li li a href po
  • 将 datagridview 从一种窗体传递到另一种 c#

    我想将我的 datagridview 从 form1 传递到 form2 我尝试使用构造函数但没有结果 第二个表单中的 datagridview 为空 有人可以帮助我吗 我已经堆积了好几个小时了 我不使用 sql 也不需要使用 dataTa
  • 如何将我的应用程序限制为单个浏览器选项卡?

    坦率地说 在 v1 0 中 需要提交三个表单的功能会带来太多麻烦 SESSION会话数据保存所有中间内容 只是让用户启动一个操作 然后打开第二个选项卡并执行第二个操作 该操作会破坏会话数据 我怀疑这是恶意的 但不能否认 更有可能的是 用户开
  • Geochart 用独特的颜色填充国家/地区,并用其颜色作为图例显示国家/地区名称 [关闭]

    Closed 这个问题需要多问focused 目前不接受答案 我需要用列表中指定的唯一颜色填充每个国家 并显示国家名称及其颜色作为地图下面的图例 如随附的图像所示 任何帮助将不胜感激
  • 如何确定 ms sql server 2005 中打开/活动连接的总数

    我的 PHP MS Sql Server 2005 win 2003 应用程序有时会变得非常无响应 内存 CPU 使用率不会飙升 如果我尝试从 sql management studio 打开任何新连接 那么它只会挂在打开的连接对话框中 如
  • 什么是 AndroidX?

    我正在阅读有关 Android 房间库的内容 我看到他们改变了包裹android to androidx 我不明白 有人可以解释一下吗 implementation androidx room room runtime room versi
  • 无法将“In-Reply-To”参数传递给 Microsoft Graph sendMail

    我允许用户使用 Microsoft Graph API 使用 Outlook 帐户发送电子邮件 但它似乎在另一端创建多个线程 当使用 Mailgun API 发送用户电子邮件时 我能够传递引用前一条消息 Message ID 的 In Re
  • 如何估计 Pandas 的 DataFrame 需要多少内存?

    我一直在想 如果我正在将一个 400MB 的 csv 文件读取到 pandas 数据帧中 使用 read csv 或 read table 有什么方法可以猜测这将需要多少内存 只是想更好地感受数据帧和内存 df memory usage 将
  • 从 Clojure 记录返回普通地图

    我有一个记录 defrecord Point x y def p Point 1 2 现在我想从记录中提取地图 这些方法可以完成工作 这些是好方法吗 还有更好的方法吗 into concat p into map identity p ap
  • 正则表达式计算字符串中逗号的数量

    如何构建一个正则表达式来匹配包含任意字符但必须包含 21 个逗号的任意长度的字符串 21 That is Start of string Start of group Any character except comma zero or m
  • 为什么使用Intent.createChooser()?

    我找到了一些发送电子邮件的代码 它看起来像这样 startActivity Intent createChooser emailIntent Email 我把它改为 startActivity emailIntent 结果在我的设备上显示相
  • 如何在 Google App Engine 中导入模块?

    我根据默认模板创建了一个简单的 GAE 应用程序 我想添加一个外部模块 例如短网址 我该怎么做呢 到目前为止 我发现的方向令人困惑 而且我猜 GAE 似乎没有使用 PYTHONPATH 原因很明显 只需将short url py文件位于应用
  • 用户取消基本身份验证后出现空白页面

    我用谷歌搜索了很多关于这个问题的信息 但仍然没有找到为什么会发生这种情况 当用户在浏览器中取消 BASIC 身份验证表单时 会出现空白页面 401页面是在Tomcat webapp中设置的 在Firebug中我可以看到401未经授权 也许响
  • 具有多个输入的 Keras 序列模型

    我正在制作一个 MLP 模型 它接受两个输入并产生一个输出 我有两个输入数组 每个输入一个 和 1 个输出数组 该神经网络有 1 个隐藏层和 2 个神经元 每个数组有 336 个元素 model0 keras Sequential kera
  • Firebase - 云功能 - 对集合进行查询

    假设我有两个包含用户和故事的顶级集合 现在每次用户的文档得到更新 只有值username or photoUrl 我想更新故事集合中文档的这些属性 一个用户文档可能如下所示 缩短 username blubber photoUrl my p
  • 在android中访问.sqlite数据库(>1Mb大小)

    我正在开发一个图书馆应用程序 并将书籍存储为 sqlite 文件 每本书的sqlite数据库文件大小约为10MB 我首先尝试将其放入资产文件夹中 然后将其复制到数据库 文件夹中 但由于文件 gt 1Mb 这给了我一个 IOException
  • MS Access 字段作为列

    如何在 MS Access 中进行查询 以便将字段分组到列中 通过例子更容易解释 Table Brand Quantity Date 1 MTZ 3 2012 03 2 MTZ 1 2012 03 3 Belor 2 2012 04 4 Y
  • 删除特定运输类别的 Woocommerce“下订单”按钮

    我有一个场景 我需要删除 Woo commerce 结帐屏幕上的 下订单 按钮 目前我有两种运输方式 灵活运输和货运 如果客户将运输类别为 货运 的商品添加到购物车 我当前的代码将禁用灵活的运输方法 然后货运方法会显示一条 致电了解当前费率
  • 无法运行 bms-samples-cordova-hellopush - 找不到 bms_samples_cordova_push-Swift.h 文件

    我正在尝试运行可用的推送通知示例GitHub 不幸的是 配置如概述here不起作用 文件说 在你的顶部AppDelegate m import your project name Swift h 如果您的项目名称包含空格或连字符 请在导入语