Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
flutter_jpush_vip
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李增强
flutter_jpush_vip
Commits
46d70639
Commit
46d70639
authored
Mar 13, 2021
by
xgz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加ios推送
parent
20412e03
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
847 additions
and
100 deletions
+847
-100
example/lib/main.dart
example/lib/main.dart
+46
-47
example/test/widget_test.dart
example/test/widget_test.dart
+0
-27
ios/Classes/FlutterJpushVipPlugin.h
ios/Classes/FlutterJpushVipPlugin.h
+2
-0
ios/Classes/FlutterJpushVipPlugin.m
ios/Classes/FlutterJpushVipPlugin.m
+753
-9
ios/Classes/SwiftFlutterJpushVipPlugin.swift
ios/Classes/SwiftFlutterJpushVipPlugin.swift
+0
-14
ios/flutter_jpush_vip.podspec
ios/flutter_jpush_vip.podspec
+5
-0
lib/flutter_jpush_vip.dart
lib/flutter_jpush_vip.dart
+41
-3
No files found.
example/lib/main.dart
View file @
46d70639
import
'package:flutter/material.dart'
;
import
'dart:async'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_jpush_vip/flutter_jpush_vip.dart'
;
void
main
(
)
{
runApp
(
MyApp
());
}
class
MyApp
extends
StatefulWidget
{
@override
_MyAppState
createState
()
=>
_MyAppState
();
}
class
_MyAppState
extends
State
<
MyApp
>
{
@override
void
initState
()
{
super
.
initState
();
FlutterJpushVip
.
init
().
then
((
value
)
{
print
(
"============
$value
"
);
});
FlutterJpushVip
.
onNotification
((
n
){
print
(
"============
$n
"
);
});
}
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
home:
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
'Plugin example app'
),
),
body:
GestureDetector
(
onTap:
()
{
},
child:
Center
(
child:
Text
(
'Running on: test'
),
)),
),
);
}
}
// import 'package:flutter/material.dart';
// import 'dart:async';
// import 'package:flutter/services.dart';
// import 'package:flutter_jpush_vip/flutter_jpush_vip.dart';
// void main() {
// runApp(MyApp());
// }
// class MyApp extends StatefulWidget {
// @override
// _MyAppState createState() => _MyAppState();
// }
// class _MyAppState extends State<MyApp> {
// @override
// void initState() {
// super.initState();
// FlutterJpushVip.init().then((value) {
// print("============$value");
// });
// FlutterJpushVip.onNotification((n){
// print("============$n");
// });
// }
// @override
// Widget build(BuildContext context) {
// return MaterialApp(
// home: Scaffold(
// appBar: AppBar(
// title: const Text('Plugin example app'),
// ),
// body: GestureDetector(
// onTap: () {
// },
// child: Center(
// child: Text('Running on: test'),
// )),
// ),
// );
// }
// }
example/test/widget_test.dart
deleted
100644 → 0
View file @
20412e03
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_jpush_vip_example/main.dart'
;
void
main
(
)
{
testWidgets
(
'Verify Platform version'
,
(
WidgetTester
tester
)
async
{
// Build our app and trigger a frame.
await
tester
.
pumpWidget
(
MyApp
());
// Verify that platform version is retrieved.
expect
(
find
.
byWidgetPredicate
(
(
Widget
widget
)
=>
widget
is
Text
&&
widget
.
data
.
startsWith
(
'Running on:'
),
),
findsOneWidget
,
);
});
}
ios/Classes/FlutterJpushVipPlugin.h
View file @
46d70639
#import <Flutter/Flutter.h>
@interface
FlutterJpushVipPlugin
:
NSObject
<
FlutterPlugin
>
@property
FlutterMethodChannel
*
channel
;
+
(
void
)
appdidLaunch
:(
NSDictionary
*
)
launchOption
;
@end
ios/Classes/FlutterJpushVipPlugin.m
View file @
46d70639
This diff is collapsed.
Click to expand it.
ios/Classes/SwiftFlutterJpushVipPlugin.swift
deleted
100644 → 0
View file @
20412e03
import
Flutter
import
UIKit
public
class
SwiftFlutterJpushVipPlugin
:
NSObject
,
FlutterPlugin
{
public
static
func
register
(
with
registrar
:
FlutterPluginRegistrar
)
{
let
channel
=
FlutterMethodChannel
(
name
:
"flutter_jpush_vip"
,
binaryMessenger
:
registrar
.
messenger
())
let
instance
=
SwiftFlutterJpushVipPlugin
()
registrar
.
addMethodCallDelegate
(
instance
,
channel
:
channel
)
}
public
func
handle
(
_
call
:
FlutterMethodCall
,
result
:
@escaping
FlutterResult
)
{
result
(
"iOS "
+
UIDevice
.
current
.
systemVersion
)
}
}
ios/flutter_jpush_vip.podspec
View file @
46d70639
...
...
@@ -16,6 +16,11 @@ Pod::Spec.new do |s|
s
.
source_files
=
'Classes/**/*'
s
.
dependency
'Flutter'
s
.
platform
=
:ios
,
'8.0'
s
.
dependency
'JCore'
,
'2.4.0'
s
.
dependency
'JPush'
,
'3.4.0'
s
.
ios
.
deployment_target
=
'10.0'
s
.
static_framework
=
true
# Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported.
s
.
pod_target_xcconfig
=
{
'DEFINES_MODULE'
=>
'YES'
,
'VALID_ARCHS[sdk=iphonesimulator*]'
=>
'x86_64'
}
...
...
lib/flutter_jpush_vip.dart
View file @
46d70639
import
'dart:async'
;
import
'dart:convert'
;
import
'dart:io'
;
import
'package:flutter/services.dart'
;
class
FlutterJpushVip
{
static
const
MethodChannel
_channel
=
const
MethodChannel
(
'flutter_jpush_vip'
);
/// 初始化
static
Future
<
_InitResult
>
init
()
async
{
var
map
=
await
_channel
.
invokeMethod
(
'init'
);
/// [production] ios only 生产环境
static
Future
<
_InitResult
>
init
({
bool
production
=
true
})
async
{
var
map
=
await
_channel
.
invokeMethod
(
'init'
,
{
'production'
:
production
});
return
_InitResult
.
from
(
map
);
}
///
/// iOS Only
/// 申请推送权限,注意这个方法只会向用户弹出一次推送权限请求(如果用户不同意,之后只能用户到设置页面里面勾选相应权限),需要开发者选择合适的时机调用。
///
void
applyPushAuthority
(
[
NotificationSettingsIOS
iosSettings
=
const
NotificationSettingsIOS
()])
{
if
(!
Platform
.
isIOS
)
{
return
;
}
_channel
.
invokeMethod
(
'applyPushAuthority'
,
iosSettings
.
toMap
());
}
/// 开启调试模式
static
void
debug
()
{
_channel
.
invokeMethod
(
'debug'
);
}
/// 获取注册ID
static
Future
<
String
>
getRegistrationID
()
{
return
_channel
.
invokeMethod
(
'getRegistrationID'
);
}
/// 清除通知
static
void
clearAllNotifications
()
{
_channel
.
invokeMethod
(
'clearAllNotifications'
);
}
/// 监听通知
static
void
onNotification
(
Function
(
_Notification
notification
)
callback
)
{
_channel
.
setMethodCallHandler
((
call
)
{
if
(
call
.
method
==
'__JPUSH_MESSAGE__'
)
{
try
{
Map
map
=
json
.
decode
(
call
.
arguments
);
Map
map
=
call
.
arguments
;
if
(
call
.
arguments
.
runtimeType
.
toString
().
contains
(
'String'
))
{
map
=
json
.
decode
(
call
.
arguments
);
}
var
n
=
_Notification
.
from
(
map
);
callback
(
n
);
}
catch
(
e
)
{
...
...
@@ -70,3 +92,19 @@ class _Notification {
return
'Notification{msgId:
$msgId
, content:
$content
, title:
$title
, extras:
$extras
, platform:
$platform
}'
;
}
}
class
NotificationSettingsIOS
{
final
bool
sound
;
final
bool
alert
;
final
bool
badge
;
const
NotificationSettingsIOS
({
this
.
sound
=
true
,
this
.
alert
=
true
,
this
.
badge
=
true
,
});
Map
<
String
,
dynamic
>
toMap
()
{
return
<
String
,
bool
>{
'sound'
:
sound
,
'alert'
:
alert
,
'badge'
:
badge
};
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment