mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-01-31 14:32:51 +08:00
iOS - update
1.更新手动安装文档 2.fix 影响其他插件使用的 bug
This commit is contained in:
parent
b02e3faef0
commit
404f19037e
@ -1,12 +1,12 @@
|
||||
### iOS 手动安装
|
||||
|
||||
下载 JPush PhoneGap 插件,并解压缩,标记插件目录为:`$JPUSH_PLUGIN_DIR`
|
||||
- 下载 JPush PhoneGap 插件,并解压缩,标记插件目录为:`$JPUSH_PLUGIN_DIR`
|
||||
|
||||
- 用 xcode 打开 iOS 工程 将 `$JPUSH_PLUGIN_DIR`/src/ios/Plugins/ 拖到 project 中
|
||||
|
||||
1. 用 xcode 打开 iOS 工程 将 `$JPUSH_PLUGIN_DIR`/src/ios/Plugins/ 拖到 project 中
|
||||
2. 将 `$JPUSH_PLUGIN_DIR`/src/ios/lib/ 拖到 project 中
|
||||
- 将 `$JPUSH_PLUGIN_DIR`/src/ios/lib/ 拖到 project 中
|
||||
|
||||
4. 添加以下框架,打开 xcode,点击 project,选择(Target -> Build Phases -> Link Binary With Libraries)
|
||||
- 添加以下框架,打开 xcode,点击 project,选择(Target -> Build Phases -> Link Binary With Libraries)
|
||||
|
||||
CFNetwork.framework
|
||||
CoreFoundation.framework
|
||||
@ -17,16 +17,16 @@
|
||||
UIKit.framework
|
||||
|
||||
|
||||
5. 在你的工程中创建一个新的 Property List 文件
|
||||
- 在你的工程中创建一个新的 Property List 文件
|
||||
|
||||
并将其命名为 PushConfig.plist,填入 Portal 为你的应用提供的 APP_KEY 等参数
|
||||
|
||||
10. 在 AppDelegate.m 中包含头文件
|
||||
- 在 AppDelegate.m 中包含头文件
|
||||
|
||||
#import "JPUSHService.h"
|
||||
#import "JPushPlugin.h"
|
||||
|
||||
6. 调用代码,监听系统事件,相应地调用 JPush SDK 提供的 API 来实现功能
|
||||
- 在 AppDelegate.m 中的下列方法中添加代码,如果方法不存在则增加相应方法与内容
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
|
||||
//原内容保持不变
|
||||
@ -43,11 +43,10 @@
|
||||
//原内容保持不变
|
||||
// Required add
|
||||
[JPUSHService handleRemoteNotification:userInfo];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kJPushPluginReceiveNotification
|
||||
object:userInfo];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kJPushPluginReceiveNotification object:userInfo];
|
||||
}
|
||||
|
||||
7. 修改 phonegap config.xml 文件用来包含 Plugin/ 内的插件
|
||||
- 修改 phonegap config.xml 文件用来包含 Plugin/ 内的插件
|
||||
|
||||
|
||||
<feature name="JPushPlugin">
|
||||
@ -56,7 +55,8 @@
|
||||
</feature>
|
||||
|
||||
|
||||
8. 复制 `$JPUSH_PLUGIN_DIR`/www/PushNotification.js 到工程的 www 目录下面
|
||||
9. 在需要使用插件处加入
|
||||
- 复制 `$JPUSH_PLUGIN_DIR`/www/JPushPlugin.js 到工程的 www 目录下面
|
||||
|
||||
- 在需要使用插件处加入
|
||||
|
||||
<script type="text/javascript" src="JPushPlugin.js"></script>
|
||||
|
@ -65,12 +65,12 @@ JPush-PhoneGap-Plugin 支持 iOS, Android 的推送插件。
|
||||
|
||||
### Android 手动安装
|
||||
|
||||
[Android 手动安装文档地址](document/Android_handle_install.md)
|
||||
[Android 手动安装文档地址](API/Android_handle_install.md)
|
||||
|
||||
|
||||
### iOS 手动安装
|
||||
|
||||
[IOS手动安装文档地址](document/iOS_handle_install.md)
|
||||
[IOS 手动安装文档地址](API/iOS_install.md)
|
||||
|
||||
|
||||
###示例
|
||||
|
@ -9,20 +9,29 @@
|
||||
#import "AppDelegate+JPush.h"
|
||||
#import "JPushPlugin.h"
|
||||
#import "JPUSHService.h"
|
||||
#import <objc/runtime.h>
|
||||
|
||||
@implementation AppDelegate (JPush)
|
||||
|
||||
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
|
||||
[JPushPlugin setLaunchOptions:launchOptions];
|
||||
+(void)load{
|
||||
|
||||
//cordova didFinishLaunchingWithOptions
|
||||
CGRect screenBounds = [[UIScreen mainScreen] bounds];
|
||||
self.window = [[UIWindow alloc] initWithFrame:screenBounds];
|
||||
self.viewController = [[CDVViewController alloc] init];
|
||||
self.window.rootViewController = self.viewController;
|
||||
self.window.autoresizesSubviews = YES;
|
||||
[self.window makeKeyAndVisible];
|
||||
return YES;
|
||||
Method origin;
|
||||
Method swizzle;
|
||||
|
||||
origin=class_getInstanceMethod([self class],@selector(init));
|
||||
swizzle=class_getInstanceMethod([self class], @selector(init_plus));
|
||||
method_exchangeImplementations(origin, swizzle);
|
||||
}
|
||||
|
||||
-(instancetype)init_plus{
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidLaunch:) name:@"UIApplicationDidFinishLaunchingNotification" object:nil];
|
||||
return [self init_plus];
|
||||
}
|
||||
|
||||
-(void)applicationDidLaunch:(NSNotification *)notification{
|
||||
if (notification) {
|
||||
[JPushPlugin setLaunchOptions:notification.userInfo];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
||||
|
Loading…
Reference in New Issue
Block a user