-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
frank
authored and
frank
committed
Aug 22, 2018
0 parents
commit 7fc7063
Showing
19 changed files
with
326 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# PgyerPlugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "pgyerplugin", | ||
"version": "1.0.0", | ||
"description": "蒲公英SDK Cordova插件", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "Frank", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0" | ||
id="com.pgyer.plugin" | ||
version="1.0.0"> | ||
|
||
<name>PgyerPlugin</name> | ||
|
||
<engines> | ||
<engine name="cordova" version=">=3.4.0"/> | ||
</engines> | ||
|
||
<asset src="www/pgyer.js" target="js/pgyer.js"/> | ||
|
||
<js-module src="www/pgyer.js" name="pgyer"> | ||
<clobbers target="pgyer" /> | ||
</js-module> | ||
|
||
<platform name="android"> | ||
<preference name="ANDROID_APPID" /> | ||
|
||
<config-file target="res/xml/config.xml" parent="/*"> | ||
<feature name="PgyerPlugin"> | ||
<param name="android-package" value="com.pgyer.plugin.PgyerPlugin"/> | ||
<param name="onload" value="true" /> | ||
</feature> | ||
</config-file> | ||
|
||
<config-file target="AndroidManifest.xml" parent="/manifest"> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 获取网络状态 --> | ||
<uses-permission android:name="android.permission.INTERNET" /> <!-- 网络通信--> | ||
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <!-- 获取设备信息 --> | ||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 获取MAC地址--> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- 读写sdcard,storage等等 --> | ||
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <!-- 允许程序录制音频 --> | ||
</config-file> | ||
<edit-config file="app/src/main/AndroidManifest.xml" target="/manifest/application" mode="merge" /> | ||
|
||
|
||
<config-file target="AndroidManifest.xml" parent="/manifest/application"> | ||
<meta-data android:name="PGYER_APPID" android:value="$ANDROID_APPID" /> | ||
<!-- 可选--> | ||
<activity android:name="com.pgyersdk.feedback.FeedbackActivity"/> | ||
<!-- 必选--> | ||
<provider | ||
android:name="com.pgyersdk.PgyerProvider" | ||
android:authorities="${applicationId}.com.pgyer.provider" | ||
android:exported="false"/> | ||
</config-file> | ||
|
||
<source-file src="src/android/pgyer_sdk_3.0.0.jar" target-dir="libs"/> | ||
|
||
<source-file src="src/android/PgyerPlugin.java" target-dir="src/com/pgyer/plugin/"/> | ||
</platform> | ||
|
||
<!-- ios --> | ||
<platform name="ios"> | ||
<preference name="IOS_APPID" /> | ||
|
||
<config-file target="config.xml" parent="/*"> | ||
<feature name="PgyerPlugin"> | ||
<param name="ios-package" value="PgyerPlugin"/> | ||
<param name="onload" value="true" /> | ||
</feature> | ||
<preference name="PGYERAPPID" value="$IOS_APPID"/> | ||
</config-file> | ||
|
||
<config-file target="*-Info.plist" parent="NSAppTransportSecurity"> | ||
<dict> | ||
<key>NSAllowsArbitraryLoads</key> | ||
<true/> | ||
</dict> | ||
</config-file> | ||
|
||
<config-file target="*-Info.plist" parent="CFBundleURLTypes"> | ||
<array> | ||
<dict> | ||
<key>CFBundleURLName</key> | ||
<string>PgyerAppID</string> | ||
<key>CFBundleURLSchemes</key> | ||
<array> | ||
<string>$IOS_APPID</string> | ||
</array> | ||
</dict> | ||
</array> | ||
</config-file> | ||
|
||
<!-- Plugin source code --> | ||
<header-file src="src/ios/PgyerPlugin.h" /> | ||
<source-file src="src/ios/PgyerPlugin.m" /> | ||
|
||
<!-- Pgyer Official --> | ||
<source-file src="src/ios/libs/" framework="true"/> | ||
<!-- <source-file src="src/ios/libs/PgySDK.framework" framework="true" />--> | ||
<!-- <source-file src="src/ios/libs/PgyUpdate.framework" framework="true" />--> | ||
|
||
<!-- Other required frameworks --> | ||
<framework src="libz.dylib" /> | ||
<framework src="libsqlite3.0.dylib" /> | ||
<framework src="CoreTelephony.framework" /> | ||
<framework src="SystemConfiguration.framework" /> | ||
<framework src="Security.framework" /> | ||
<framework src="libstdc++.6.dylib" /> | ||
</platform> | ||
</plugin> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.pgyer.plugin; | ||
|
||
import org.apache.cordova.*; | ||
import org.json.JSONArray; | ||
import org.json.JSONException; | ||
|
||
import com.pgyersdk.feedback.PgyerFeedbackManager; | ||
import com.pgyersdk.crash.PgyCrashManager; | ||
import com.pgyersdk.update.DownloadFileListener; | ||
import com.pgyersdk.update.PgyUpdateManager; | ||
import com.pgyersdk.update.UpdateManagerListener; | ||
import com.pgyersdk.update.javabean.AppBean; | ||
|
||
import android.content.pm.ApplicationInfo; | ||
import android.content.pm.PackageManager; | ||
import android.content.pm.PackageManager.NameNotFoundException; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
|
||
|
||
public class PgyerPlugin extends CordovaPlugin { | ||
private static String TAG = "PgyerPlugin"; | ||
|
||
|
||
@Override | ||
public boolean execute(String action, JSONArray data, CallbackContext callbackContext) throws JSONException { | ||
|
||
String androidAppId = ""; | ||
try { | ||
ApplicationInfo applicationInfo = this.cordova.getActivity().getPackageManager().getApplicationInfo(this.cordova.getActivity().getPackageName(), PackageManager.GET_META_DATA); | ||
Bundle bundle = applicationInfo.metaData; | ||
androidAppId = bundle.getString("PGYER_APPID"); | ||
} catch (NameNotFoundException e) { | ||
Log.e(TAG, "Failed to load meta-data, NameNotFound: " + e.getMessage()); | ||
} catch (NullPointerException e) { | ||
Log.e(TAG, "Failed to load meta-data, NullPointer: " + e.getMessage()); | ||
} | ||
|
||
if (androidAppId.equals("")) { | ||
return false; | ||
} | ||
|
||
final String appId = androidAppId; | ||
|
||
if (action.equals("showFeedback")) { | ||
new PgyerFeedbackManager.PgyerFeedbackBuilder() | ||
.setShakeInvoke(false) //fasle 则不触发摇一摇,最后需要调用 invoke 方法 | ||
// true 设置需要调用 register 方法使摇一摇生效 | ||
.setDisplayType(PgyerFeedbackManager.TYPE.DIALOG_TYPE) //设置以Dialog 的方式打开 | ||
.setColorDialogTitle("#FF0000") //设置Dialog 标题的字体颜色,默认为颜色为#ffffff | ||
.setColorTitleBg("#FF0000") //设置Dialog 标题栏的背景色,默认为颜色为#2E2D2D | ||
.setBarBackgroundColor("#FF0000") // 设置顶部按钮和底部背景色,默认颜色为 #2E2D2D | ||
.setBarButtonPressedColor("#FF0000") //设置顶部按钮和底部按钮按下时的反馈色 默认颜色为 #383737 | ||
.setColorPickerBackgroundColor("#FF0000") //设置颜色选择器的背景色,默认颜色为 #272828 | ||
.setMoreParam("KEY1", "VALUE1") //自定义的反馈数据 | ||
.setMoreParam("KEY2", "VALUE2") //自定义的反馈数据 | ||
.builder() | ||
.invoke(); //激活直接显示的方式 | ||
return true; | ||
} | ||
if (action.equals("crashRegister")) { | ||
PgyCrashManager.register(); | ||
return true; | ||
} | ||
if (action.equals("checkUpdate")) { | ||
/** 默认方式 **/ | ||
new PgyUpdateManager.Builder() | ||
.register(); | ||
return true; | ||
|
||
} | ||
|
||
return false; | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// | ||
// PgyManager.h | ||
// PgySDK | ||
// | ||
// Created by Scott Lei on 2015-1-7. | ||
// Copyright (c) 2015年 蒲公英. All rights reserved. | ||
// Version: 2.3 | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <UIKit/UIKit.h> | ||
|
||
/** | ||
* 激活反馈功能的方式 | ||
*/ | ||
typedef NS_ENUM(NSInteger, KPGYFeedbackActiveType){ | ||
/** | ||
* 摇晃手机激活用户反馈界面 | ||
*/ | ||
kPGYFeedbackActiveTypeShake = 0, | ||
/** | ||
* 在界面上三指下滑或者上滑激活用户反馈界面 | ||
*/ | ||
kPGYFeedbackActiveTypeThreeFingersPan = 1, | ||
}; | ||
|
||
@interface PgyManager : NSObject | ||
|
||
/** | ||
* 是否显示蒲公英SDK的Debug Log,如果遇到SDK无法正常工作的情况可以开启此标志以确认原因,默认为关闭。 | ||
*/ | ||
@property (nonatomic, assign, getter = isDebugLogEnabled) BOOL enableDebugLog; | ||
|
||
/** | ||
* 激活用户反馈的方式,如果不设置的话,则默认为摇一摇激活用户反馈界面。 | ||
* 设置激活用户反馈方式需在调用 - (void)startManagerWithAppId:(NSString *)appId 之前。 | ||
*/ | ||
@property (nonatomic, assign) KPGYFeedbackActiveType feedbackActiveType; | ||
|
||
/** | ||
* 开启或关闭用户手势反馈功能,默认为开启。 | ||
*/ | ||
@property (nonatomic, assign, getter=isFeedbackEnabled) BOOL enableFeedback; | ||
|
||
/** | ||
* 设置用户反馈界面的颜色,颜色会影响到Title以及工具栏的背景颜色和录音按钮的边框颜色,默认为黑色。 | ||
*/ | ||
@property (nonatomic, retain) UIColor *themeColor; | ||
|
||
/** | ||
* 激活用户反馈界面的阈值,数字越小灵敏度越高,默认为2.3。 | ||
*/ | ||
@property (nonatomic, assign) double shakingThreshold; | ||
|
||
/** | ||
* 初始化蒲公英SDK | ||
* | ||
* @return PgyManger的单例对象 | ||
*/ | ||
+ (PgyManager *)sharedPgyManager; | ||
|
||
/** | ||
* 启动蒲公英SDK | ||
* 如果需要自定义用户反馈激活模式,则需要在调用此方法之前设置。 | ||
* @param appId 应用程序ID,从蒲公英网站上获取。 | ||
*/ | ||
- (void)startManagerWithAppId:(NSString *)appId; | ||
|
||
/** | ||
* 显示用户反馈界面 | ||
*/ | ||
- (void)showFeedbackView; | ||
|
||
/** | ||
* 上报Exception,Exception的name,reason,callStackSymbols会被上报至蒲公英服务器。 | ||
* | ||
* @param exception 异常 | ||
*/ | ||
- (void)reportException:(NSException *)exception; | ||
|
||
@end |
Binary file not shown.
Binary file not shown.
Binary file not shown.
42 changes: 42 additions & 0 deletions
42
src/ios/libs/PgyUpdate.framework/Headers/PgyUpdateManager.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// PgyUpdateManager.h | ||
// Pods | ||
// | ||
// Created by Scott Lei on 15/9/16. | ||
// | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface PgyUpdateManager : NSObject | ||
|
||
+ (PgyUpdateManager *)sharedPgyManager; | ||
|
||
/** | ||
* 启动蒲公英SDK | ||
* @param appId 应用程序ID,从蒲公英网站上获取。 | ||
*/ | ||
- (void)startManagerWithAppId:(NSString *)appId; | ||
|
||
/** | ||
* 检查是否有版本更新。 | ||
* 如果开发者在蒲公英上提交了新版本,则调用此方法后会弹出更新提示界面。 | ||
*/ | ||
- (void)checkUpdate; | ||
|
||
/** | ||
* 检查是否有版本更新。 | ||
* | ||
* @param delegate 自定义checkUpdateWithDelegete方法的对象 | ||
* @param updateMethodWithDictionary 当checkUpdateWithDelegete事件完成时此方法会被调用,包含更新信息的字典也被回传。 | ||
* 如果有更新信息,那么字典里就会包含新版本的信息,否则的话字典信息为nil。 | ||
*/ | ||
- (void)checkUpdateWithDelegete:(id)delegate selector:(SEL)updateMethodWithDictionary; | ||
|
||
/** | ||
* 检查更新是根据本地存储的Build号和蒲公英上的最新Build号比较来完成的。如果调用checkUpdateWithDelegete,SDK会获取到最新的 | ||
* Build号,但是checkUpdateWithDelegete方法自己不会来更新本地版本号,如果需要更新本地版本号,则需要调用此方法。 | ||
*/ | ||
- (void)updateLocalBuildNumber; | ||
|
||
@end |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
var exec = require('cordova/exec'); | ||
|
||
exports.showFeedback= function (arg0, success, error) { | ||
exec(success, error, 'PgyerPlugin', 'showFeedback', [arg0]); | ||
}; | ||
|
||
exports.crashRegister= function (arg0, success, error) { | ||
exec(success, error, 'PgyerPlugin', 'crashRegister', [arg0]); | ||
}; | ||
|
||
exports.checkUpdate= function (arg0, success, error) { | ||
exec(success, error, 'PgyerPlugin', 'checkUpdate', [arg0]); | ||
}; |