index.uts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. export class Mycallback{
  2. callback : ((resp : UTSJSONObject) => void) | null = null
  3. onCallback(handle : (resp : any) => void) {
  4. this.callback = handle
  5. if(MyPluginClass.currentself!=null){
  6. MyPluginClass.currentself.callback = handle;
  7. }
  8. }
  9. }
  10. export class MyPluginClass implements UTSiOSHookProxy {
  11. // uts 插件创建时的回调。
  12. static currentself : MyPluginClass | null = null
  13. callback : ((resp : any) => void) | null = null
  14. onCreate(){
  15. }
  16. // 应用正常启动时 (不包括已在后台转到前台的情况)的回调函数。
  17. applicationDidFinishLaunchingWithOptions(application: UIApplication | null, launchOptions: Map<UIApplication.LaunchOptionsKey, any> | null = null): boolean {
  18. // console.log("applicationDidFinishLaunchingWithOptions")
  19. MyPluginClass.currentself = this;
  20. return false
  21. }
  22. // 远程通知注册成功时的回调函数。(打自定义基座时需要勾选 push 模块)
  23. didRegisterForRemoteNotifications(deviceToken: Data | null) {
  24. }
  25. // 远程通知注册失败时的回调函数。(打自定义基座时需要勾选 push 模块)
  26. didFailToRegisterForRemoteNotifications(error: NSError | null) {
  27. }
  28. // 应用收到远程通知时的回调函数。(打自定义基座时需要勾选 push 模块)
  29. didReceiveRemoteNotification(userInfo: Map<AnyHashable, any> | null) {
  30. // console.log("didReceiveRemoteNotification")
  31. this.callback?.(userInfo)
  32. }
  33. // 应用收到本地通知时的回调函数。(打自定义基座时需要勾选 push 模块)
  34. didReceiveLocalNotification(notification: UILocalNotification | null) {
  35. // console.log("didReceiveLocalNotification")
  36. }
  37. // 应用程序的 main 函数。
  38. applicationMain(argc: Int32, argv: UnsafeMutablePointer<UnsafeMutablePointer<CChar> | null>) {
  39. console.log("applicationMain")
  40. }
  41. }