问题描述
当我查看文档时,它告诉我 -5 与 proguard 规则有关,因此我按照此处所述添加了它们。 https://developer.huawei.com/consumer/en/doc/development/HMSCore-References-V5/error-code-0000001050255690-V5
android/proguard-rules.pro
## Flutter wrapper
-keep class io.Flutter.app.** { *; }
-keep class io.Flutter.plugin.** { *; }
-keep class io.Flutter.util.** { *; }
-keep class io.Flutter.view.** { *; }
-keep class io.Flutter.** { *; }
-keep class io.Flutter.plugins.** { *; }
-dontwarn io.Flutter.embedding.**
## HMS Core SDK
-ignorewarnings
-keepattributes *Annotation*
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes Signature
-keepattributes SourceFile,LineNumberTable
-keep class com.huawei.hianalytics.**{*;}
-keep class com.huawei.updatesdk.**{*;}
-keep class com.huawei.hms.**{*;}
android/app/build.gradle 部分:
buildTypes {
release {
// Todo: Add your own signing config for the release build.
// Signing with the debug keys for Now,so `Flutter run --release` works.
signingConfig signingConfigs.release
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
String _token = '';
@override
void initState() {
HwAds.init();
initPush();
super.initState();
}
Future<void> initPush() async {
if (!mounted) return;
Push.getTokenStream.listen(_onTokenEvent,onError: _onTokenError);
}
void _onTokenEvent(String event) {
print('onTokenEvent');
_token = event;
showResult("TokenEvent",_token);
}
void _onTokenError(Object error) {
print('onTokenError');
PlatformException e = error;
showResult("TokenErrorEvent",e.message);
}
void showResult(String name,[String msg = "Button pressed."]) {
print('$name: $msg');
if (msg.isNotEmpty) Push.showToast(msg);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Home'),),body: SingleChildScrollView(
child: Column(
children: [
RaisedButton(
child: Text('Interstitial Ad Page'),onpressed: ()=> Navigator.pushNamed(context,'/interstitialPage'),RaisedButton(
child: Text('Get token'),onpressed: ()=> Push.getToken(''),],);
}
}
我正在使用云调试,型号名称是 P40。我创建了一个发布 apk,选择了数据存储位置,提供了 SHA256,启用了 Push Kit,在启用 push kit 后更新了 agconnect-services。还有什么我遗漏的吗?
解决方法
您可以尝试添加
(node:14500) UnhandledPromiseRejectionWarning: TypeError: channel.overwritePermissions is not a function
at C:\Users\Admin\Desktop\Discord bot\BOT SHOT\commands\repeat1.js:9:29
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:14500) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block,or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection,use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:14500) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future,promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
到你的 proguard-rules.pro
检查这个官方样本
,希望我的回答能帮到你
尝试调用 getToken 来生成令牌,然后调用 getTokenStrem,这对我有用
Push.getToken('');
final token = await Push.getTokenStream.first;
不,我只是很困惑我应该在 Scope 中发送什么,而不是空存储