推送,ios/android,test

This commit is contained in:
xj.deng
2019-06-18 11:09:23 +08:00
parent 18a6300297
commit db9c4caba6
9 changed files with 119 additions and 3 deletions

View File

@ -51,8 +51,23 @@ android {
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [
JPUSH_PKGNAME : "com.alibaba.fluttergo",
JPUSH_APPKEY : "62eb07d227d1f11dd7fa6239", //JPush上注册的包名对应的appkey.
JPUSH_CHANNEL : "developer-default",
]
// ndk {
// //选择要添加的对应cpu类型的.so库。
// abiFilters 'armeabi', 'armeabi-v7a','x86', 'x86_64', 'mips'//, 'arm64-v8a'
// // 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
// }
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
@ -86,6 +101,8 @@ dependencies {
///implementation 'com.google.firebase:firebase-perf:16.2.3'
// 登陆
////implementation 'com.google.firebase:firebase-auth:16.0.3'
}
//firebase
apply plugin: 'com.google.gms.google-services'

View File

@ -72,6 +72,7 @@
0828E494220692B500A59437 /* iPhone XR Landscape.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "iPhone XR Landscape.png"; sourceTree = "<group>"; };
0828E4A42206936100A59437 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
084A20872202E4FD00428FF5 /* flutter go.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "flutter go.png"; sourceTree = "<group>"; };
10D9E78922B7651B003C2C98 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
@ -184,6 +185,7 @@
97C146F01CF9000F007C117D /* Runner */ = {
isa = PBXGroup;
children = (
10D9E78922B7651B003C2C98 /* Runner.entitlements */,
94722E5B22511D3600F63900 /* GoogleService-Info.plist */,
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */,
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */,
@ -246,6 +248,11 @@
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = 4WLT68XRNA;
ProvisioningStyle = Manual;
SystemCapabilities = {
com.apple.Push = {
enabled = 1;
};
};
};
};
};
@ -530,7 +537,8 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = Launch2;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 4WLT68XRNA;
@ -547,7 +555,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.alibaba.fluttergo;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = FlutterGO_alibaba_distribution_app_store;
PROVISIONING_PROFILE_SPECIFIER = "FlutterGO-alibaba-develop";
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
@ -558,6 +566,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = Launch2;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";

View File

@ -0,0 +1,8 @@
<?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>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@ -1,5 +1,6 @@
#include "AppDelegate.h"
#include "GeneratedPluginRegistrant.h"
#include "FlutterJPushPlugin.h"
@import Firebase;// firebase
@ -10,6 +11,8 @@
[FIRApp configure];// firebase
[self startupJPush:launchOptions appKey:@"62eb07d227d1f11dd7fa6239" channel:@"jpush" isProduction:FALSE];
[GeneratedPluginRegistrant registerWithRegistry:self];
// Override point for customization after application launch.
[NSThread sleepForTimeInterval:2];

View File

@ -22,6 +22,8 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSCameraUsageDescription</key>

View File

@ -0,0 +1,8 @@
<?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>
</dict>
</plist>

View File

@ -12,6 +12,7 @@ import 'package:flutter_go/utils/analytics.dart' as Analytics;
import 'package:flutter_go/views/login_page/login_page.dart';
import 'package:flutter_go/utils/data_utils.dart';
import 'package:flutter_go/model/user_info.dart';
import 'package:flutter_jpush/flutter_jpush.dart';
//import 'views/welcome_page/index.dart';
@ -36,10 +37,61 @@ class _MyAppState extends State<MyApp> {
bool _hasLogin = false;
bool _isLoading = true;
UserInformation _userInfo;
bool isConnected = false;
String registrationId;
List notificationList = [];
@override
void initState() {
super.initState();
_startupJpush();
FlutterJPush.addConnectionChangeListener((bool connected) {
setState(() {
/// 是否连接,连接了才可以推送
print("连接状态改变:$connected");
this.isConnected = connected;
if (connected) {
//在启动的时候会去连接自己的服务器,连接并注册成功之后会返回一个唯一的设备号
FlutterJPush.getRegistrationID().then((String regId) {
print("主动获取设备号:$regId");
setState(() {
this.registrationId = regId;
});
});
}
});
});
FlutterJPush
.addReceiveNotificationListener((JPushNotification notification) {
setState(() {
/// 收到推送
print("收到推送提醒: $notification");
notificationList.add(notification);
});
});
FlutterJPush
.addReceiveOpenNotificationListener((JPushNotification notification) {
setState(() {
print("打开了推送提醒: $notification");
/// 打开了推送提醒
notificationList.add(notification);
});
});
FlutterJPush.addReceiveCustomMsgListener((JPushMessage msg) {
setState(() {
print("收到推送消息提醒: $msg");
/// 打开了推送提醒
notificationList.add(msg);
});
});
DataUtils.checkLogin().then((hasLogin) {
if (hasLogin.runtimeType == UserInformation) {
setState(() {
@ -105,6 +157,15 @@ class _MyAppState extends State<MyApp> {
}
}
void _startupJpush() async {
print("初始化jpush");
await FlutterJPush.startup();
print("初始化jpush成功");
}
void main() async {
final provider = new Provider();
await provider.init(true);

View File

@ -125,6 +125,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.7"
flutter_jpush:
dependency: "direct main"
description:
name: flutter_jpush
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.4"
flutter_markdown:
dependency: "direct main"
description:
@ -213,7 +220,7 @@ packages:
name: open_file
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
version: "2.0.3"
package_info:
dependency: "direct main"
description:

View File

@ -47,6 +47,7 @@ dependencies:
permission_handler: ^3.0.0
open_file: ^2.0.1+2
package_info: ^0.4.0+3
flutter_jpush: ^0.0.4
dev_dependencies:
flutter_test: