Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use this plugin? #1

Closed
qingtian0622 opened this issue Feb 15, 2022 · 11 comments
Closed

how to use this plugin? #1

qingtian0622 opened this issue Feb 15, 2022 · 11 comments

Comments

@qingtian0622
Copy link

eg http://racconcity//invite?rid=257#target=out

how to define the scheme
final ProtocolScheme scheme = ProtocolScheme( appName: 'Test App', scheme: 'some-thing-that-doesnt-exist', appPath: Platform.resolvedExecutable, );

and how to listen the callback?

@zyrouge
Copy link
Owner

zyrouge commented Feb 15, 2022

I'm not sure if it works with https, but the plugin can be use to create custom schemes like creating chrome://. And the class doesn't do anything, you should use the methods to actually create one. All the methods return a future with a value or void.

@qingtian0622
Copy link
Author

se to create custom schemes l

for example,I have a url like "http://racconcity//invite?rid=257#target=out",how can i use your plugin to define the scheme,I don't know how to use in flutter project, your example is too simple to learn~

@zyrouge
Copy link
Owner

zyrouge commented Feb 17, 2022

se to create custom schemes l

for example,I have a url like "http://racconcity//invite?rid=257#target=out",how can i use your plugin to define the scheme,I don't know how to use in flutter project, your example is too simple to learn~

I'm not sure about using https:// but you can create something like racconcity://invite?rid=257... (scheme is racconcity) with this.

@qingtian0622
Copy link
Author

racconcity

like final ProtocolScheme scheme = ProtocolScheme( appName: 'hxs', scheme: 'racconcity', appPath: Platform.resolvedExecutable, ); ?

and how to get the params

@zyrouge
Copy link
Owner

zyrouge commented Feb 17, 2022

racconcity

like final ProtocolScheme scheme = ProtocolScheme( appName: 'hxs', scheme: 'racconcity', appPath: Platform.resolvedExecutable, ); ?

and how to get the params

You can only register schemes. Currently flutter will create another instance of the app, so you should find a way to handle those. Fyi, the args from the main functions contains the link.

@qingtian0622
Copy link
Author

You can only register schemes. Currently flutter will create another instance of the app, so you should find a way to handle those. Fyi, the args from the main functions contains the link.

where should I use the main method , `Future main(List args) async {
/** Get the registry */
final ProtocolRegistryModel registry = getRegistry();

/** Query */
await registry.find(scheme);
await registry.exists(scheme);

/** Add */
await registry.add(scheme);

/** Remove */
await registry.remove(scheme);
}`

@zyrouge
Copy link
Owner

zyrouge commented Feb 17, 2022

You can only register schemes. Currently flutter will create another instance of the app, so you should find a way to handle those. Fyi, the args from the main functions contains the link.

where should I use the main method , `Future main(List args) async { /** Get the registry */ final ProtocolRegistryModel registry = getRegistry();

/** Query */ await registry.find(scheme); await registry.exists(scheme);

/** Add */ await registry.add(scheme);

/** Remove */ await registry.remove(scheme); }`

https://dart.dev/guides/language/language-tour#the-main-function

@zyrouge
Copy link
Owner

zyrouge commented Feb 17, 2022

Again, you should handle those arguments. This package will only set the protocol pointing to your app path.

@qingtian0622
Copy link
Author

Again, you should handle those arguments. This package will only set the protocol pointing to your app path.

this is my main method.

void main() { Global.init(() { ApiConfig.env=ServerEnv.Product; }); }

now I should change it like your main method. is ok?

@qingtian0622
Copy link
Author

`import 'dart:io';

import 'package:flutter_hxs_win/base/global.dart';
import 'package:flutter_hxs_win/net/api_config.dart';
import 'package:protocol_registry/platforms/model.dart';
import 'package:protocol_registry/protocol_registry.dart';

final ProtocolScheme scheme = ProtocolScheme(
appName: 'hxs',
scheme: 'racconcity',
appPath: Platform.resolvedExecutable,
);

Future main(List args) async {
/** Get the registry */
final ProtocolRegistryModel registry = getRegistry();

/** Query */
await registry.find(scheme);
await registry.exists(scheme);

/** Add */
await registry.add(scheme);

/** Remove */
await registry.remove(scheme);

Global.init(() {
ApiConfig.env=ServerEnv.Product;
});
}`

@zyrouge
Copy link
Owner

zyrouge commented Feb 24, 2022

`import 'dart:io';

import 'package:flutter_hxs_win/base/global.dart'; import 'package:flutter_hxs_win/net/api_config.dart'; import 'package:protocol_registry/platforms/model.dart'; import 'package:protocol_registry/protocol_registry.dart';

final ProtocolScheme scheme = ProtocolScheme( appName: 'hxs', scheme: 'racconcity', appPath: Platform.resolvedExecutable, );

Future main(List args) async { /** Get the registry */ final ProtocolRegistryModel registry = getRegistry();

/** Query */ await registry.find(scheme); await registry.exists(scheme);

/** Add */ await registry.add(scheme);

/** Remove */ await registry.remove(scheme);

Global.init(() { ApiConfig.env=ServerEnv.Product; }); }`

That's up to you. You don't need to copy the code exactly.

@zyrouge zyrouge closed this as completed Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants