Commit 8fa0e5f0 authored by 李增强's avatar 李增强

m

parent 1ed9f207
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
...@@ -14,15 +14,7 @@ ...@@ -14,15 +14,7 @@
</intent-filter> </intent-filter>
</service> </service>
<receiver
android:name=".XReceiver"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
<receiver <receiver
android:name="cn.jpush.android.service.PushReceiver" android:name="cn.jpush.android.service.PushReceiver"
android:enabled="true" android:enabled="true"
...@@ -44,5 +36,9 @@ ...@@ -44,5 +36,9 @@
<data android:scheme="package" /> <data android:scheme="package" />
</intent-filter> </intent-filter>
</receiver> </receiver>
<activity
android:name=".XActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
</application> </application>
</manifest> </manifest>
package com.qiaomeng.flutter.flutter_jpush_vip;
import android.app.Activity;
import android.os.Bundle;
import android.view.WindowManager;
import androidx.annotation.Nullable;
public class XActivity extends Activity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
}
package com.qiaomeng.flutter.flutter_jpush_vip; package com.qiaomeng.flutter.flutter_jpush_vip;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import cn.jpush.android.api.NotificationMessage;
import cn.jpush.android.service.JPushMessageReceiver; import cn.jpush.android.service.JPushMessageReceiver;
public class XReceiver extends JPushMessageReceiver { public class XReceiver extends JPushMessageReceiver {
} }
...@@ -7,39 +7,36 @@ ...@@ -7,39 +7,36 @@
FlutterApplication and put your custom class here. --> FlutterApplication and put your custom class here. -->
<application <application
android:name="io.flutter.app.FlutterApplication" android:name="io.flutter.app.FlutterApplication"
android:icon="@mipmap/ic_launcher" android:label="flutter_jpush_vip_example"
android:label="flutter_jpush_vip_example"> android:icon="@mipmap/ic_launcher">
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTask" android:launchMode="singleTask"
android:theme="@style/LaunchTheme" android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize"> android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<!-- Specifies an Android theme to apply to this Activity as soon as <!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. --> to determine the Window background behind the Flutter UI. -->
<meta-data <meta-data
android:name="io.flutter.embedding.android.NormalTheme" android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" /> android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen <!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of gap between the end of Android's launch screen and the painting of
Flutter's first frame. --> Flutter's first frame. -->
<meta-data <meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable" android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" /> android:resource="@drawable/launch_background"
/>
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
</activity> </activity>
<!-- Don't delete the meta-data below. <!-- Don't delete the meta-data below.
...@@ -48,6 +45,14 @@ ...@@ -48,6 +45,14 @@
android:name="flutterEmbedding" android:name="flutterEmbedding"
android:value="2" /> android:value="2" />
<receiver
android:name=".XXXReceiver"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
</application> </application>
</manifest> </manifest>
package com.qiaomeng.flutter.flutter_jpush_vip_example; package com.qiaomeng.flutter.flutter_jpush_vip_example;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.qiaomeng.flutter.flutter_jpush_vip.Handler; import com.qiaomeng.flutter.flutter_jpush_vip.Handler;
...@@ -34,10 +36,14 @@ public class MainActivity extends FlutterActivity { ...@@ -34,10 +36,14 @@ public class MainActivity extends FlutterActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
handler.debug(); handler.debug();
handler.init(); handler.init();
// handleOpenClick();
System.out.println("===========================" + handler.getRegistrationID()); }
handleOpenClick();
@Override
protected void onNewIntent(@NonNull Intent intent) {
super.onNewIntent(intent);
System.out.println("========================"+intent.getExtras());
} }
/** /**
...@@ -57,7 +63,7 @@ public class MainActivity extends FlutterActivity { ...@@ -57,7 +63,7 @@ public class MainActivity extends FlutterActivity {
if(TextUtils.isEmpty(data) && getIntent().getExtras() != null){ if(TextUtils.isEmpty(data) && getIntent().getExtras() != null){
data = getIntent().getExtras().getString("JMessageExtra"); data = getIntent().getExtras().getString("JMessageExtra");
} }
System.out.println("==================="+getIntent().getExtras()); System.out.println("==================="+getIntent());
Log.w(TAG, "msg content is " + String.valueOf(data)); Log.w(TAG, "msg content is " + String.valueOf(data));
if (TextUtils.isEmpty(data)) return; if (TextUtils.isEmpty(data)) return;
......
package com.qiaomeng.flutter.flutter_jpush_vip_example;
import android.content.Context;
import android.content.Intent;
import com.qiaomeng.flutter.flutter_jpush_vip.XReceiver;
import cn.jpush.android.api.NotificationMessage;
public class XXXReceiver extends XReceiver {
@Override
public void onNotifyMessageOpened(Context context, NotificationMessage notificationMessage) {
// System.out.println("========"+notificationMessage.toString());
Intent i = new Intent(context, MainActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(i);
}
}
...@@ -19,7 +19,6 @@ class _MyAppState extends State<MyApp> { ...@@ -19,7 +19,6 @@ class _MyAppState extends State<MyApp> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
initPlatformState();
} }
// Platform messages are asynchronous, so we initialize in an async method. // Platform messages are asynchronous, so we initialize in an async method.
...@@ -49,9 +48,13 @@ class _MyAppState extends State<MyApp> { ...@@ -49,9 +48,13 @@ class _MyAppState extends State<MyApp> {
appBar: AppBar( appBar: AppBar(
title: const Text('Plugin example app'), title: const Text('Plugin example app'),
), ),
body: Center( body: GestureDetector(
child: Text('Running on: $_platformVersion\n'), onTap: () {
), initPlatformState();
},
child: Center(
child: Text('Running on: $_platformVersion\n'),
)),
), ),
); );
} }
......
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
class NoticeUtils {
static FlutterLocalNotificationsPlugin notificationsPlugin;
// 初始化
static void init(Function(String payload) callback) {
notificationsPlugin = FlutterLocalNotificationsPlugin();
AndroidInitializationSettings android =
AndroidInitializationSettings('@mipmap/ic_launcher');
IOSInitializationSettings ios = IOSInitializationSettings();
notificationsPlugin
.initialize(InitializationSettings(android: android, iOS: ios),
onSelectNotification: (String payload) async {
callback(payload);
});
}
// 清除通知
static void cancel({int id}){
if(id == null || id == 0){
notificationsPlugin.cancelAll();
return;
}
notificationsPlugin.cancel(id);
}
}
...@@ -76,6 +76,20 @@ packages: ...@@ -76,6 +76,20 @@ packages:
relative: true relative: true
source: path source: path
version: "0.0.1" version: "0.0.1"
flutter_local_notifications:
dependency: "direct main"
description:
name: flutter_local_notifications
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.2"
flutter_local_notifications_platform_interface:
dependency: transitive
description:
name: flutter_local_notifications_platform_interface
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.0+1"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
...@@ -116,6 +130,20 @@ packages: ...@@ -116,6 +130,20 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.4.0" version: "2.4.0"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.2.1"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.3"
quiver: quiver:
dependency: transitive dependency: transitive
description: description:
...@@ -170,6 +198,13 @@ packages: ...@@ -170,6 +198,13 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.2.15" version: "0.2.15"
timezone:
dependency: transitive
description:
name: timezone
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.5.9"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
...@@ -193,4 +228,4 @@ packages: ...@@ -193,4 +228,4 @@ packages:
version: "3.6.1" version: "3.6.1"
sdks: sdks:
dart: ">=2.7.0 <3.0.0" dart: ">=2.7.0 <3.0.0"
flutter: ">=1.10.0" flutter: ">=1.12.13+hotfix.5"
...@@ -19,6 +19,7 @@ dependencies: ...@@ -19,6 +19,7 @@ dependencies:
# The example app is bundled with the plugin so we use a path dependency on # The example app is bundled with the plugin so we use a path dependency on
# the parent directory to use the current plugin's version. # the parent directory to use the current plugin's version.
path: ../ path: ../
flutter_local_notifications: 3.0.2
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment