如何将Hockey App与Hybrid移动应用程序集成 [英] How to integrate hockey App with Hybrid mobile app

查看:143
本文介绍了如何将Hockey App与Hybrid移动应用程序集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将混合移动应用(Inonic + Cordova)与曲棍球应用集成
但问题是曲棍球应用程序支持原生应用程序(根据我的信息)。那么有没有可用的指南?
混合应用程序与曲棍球应用程序集成

I am trying to integrate my Hybrid Mobile App (Inonic + Cordova) with hockey App but the problem is Hockey App is support Native apps (According to my info). So is there any guide available for that? Hybrid App integration with Hockey app.

当我尝试跟踪曲棍球应用程序与 android平台集成(混合应用程序)它还说我在主要活动中添加一些代码,以便我可以找到这个

When I try to follow hockey app integration with android platform (hybrid app) it also said me to add some code in main activity so where i can find this

推荐答案

主要活动在Android平台内... cordova / platforms / android / src /...

Main activity is inside Android platform... cordova/platforms/android/src/...

将onCreate方法放入注册...

Put in onCreate method the Register...

还有一些插件可以帮助完成这项任务,例如 https://github.com/peutetre/cordova-plugin-hockeyapp

There also some plugins for help in this task like https://github.com/peutetre/cordova-plugin-hockeyapp

考虑到很多崩溃JavaScript问题都不会在本机崩溃使用其他方式传递受控错误会有所帮助,例如saveException方法,尝试通过插件将其暴露到javascript中,它会让存储上下文信息错误: http://hockeyapp.net/help/sdk/android/3.0.1/net/hockeyapp /android/ExceptionHandler.html

Take into account that a lot of crash JavaScript problems do not crash in native world it would be helpful to use additional way to communicate controlled errors for example the saveException method, try to expose this by plugin into javascript, it will let store context information error: http://hockeyapp.net/help/sdk/android/3.0.1/net/hockeyapp/android/ExceptionHandler.html

我在前面提到的插件的一个分支中测试了解决方案仅适用于Android
https://github.com/m-alcu/cordova-plugin-hockeyapp

I have tested the solution for Android only in a fork of the previous mentioned plugin: https://github.com/m-alcu/cordova-plugin-hockeyapp

有几个可用的操作但你只需要使用start和saveException来控制错误发送到hockeyapps。

There are several actions available but yo only need to use "start" and "saveException" for controlled errors to be send to hockeyapps.

hockeyapp.js:

hockeyapp.js:

var exec = require('cordova/exec');

var hockeyapp = {
    start:function(success, failure, token) {
        exec(success, failure, "HockeyApp", "start", [ token ]);
    },
    feedback:function(success, failure) {
        exec(success, failure, "HockeyApp", "feedback", []);
    },
    saveException:function(success, failure, description) {
        exec(success, failure, "HockeyApp", "saveException", [ description ]);
    }    
};

module.exports = hockeyapp;

hockeyapp.java:

hockeyapp.java:

package com.zengularity.cordova.hockeyapp;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.json.JSONArray;
import android.widget.Toast;

import static net.hockeyapp.android.ExceptionHandler.saveException;
import net.hockeyapp.android.FeedbackManager;
import net.hockeyapp.android.CrashManager;
import net.hockeyapp.android.CrashManagerListener;

public class HockeyApp extends CordovaPlugin {

    public static boolean initialized = false;
    public static String token;
    public static String description;

    @Override
    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) {
        if (action.equals("start")) {
            token = args.optString(0);
            CrashManager.register(cordova.getActivity(), token, null);
            initialized = true;
            callbackContext.success();
            return true;
        } else if(action.equals("feedback")) {
            token = args.optString(0);
            FeedbackManager.register(cordova.getActivity(), token, null);
            cordova.getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    FeedbackManager.showFeedbackActivity(cordova.getActivity());
                }
            });
            callbackContext.success();
            return true;

        } else if(action.equals("saveException")) {
            description = args.optString(0);
            if(initialized) {

            Toast toast = Toast.makeText(cordova.getActivity(), "problem", Toast.LENGTH_SHORT);
            toast.show();

            cordova.getActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Exception e = new Exception("Send problem");
                        saveException(e, new CrashManagerListener() {
                            public String getDescription() {
                                return description;
                            }
                        });
                    }
                });
                callbackContext.success();
                return true;
            } else {
                callbackContext.error("cordova hockeyapp plugin not initialized, call start() first");
                return false;                
            }  
        }
        else {
            return false;
        }
    }

}

示例在hellowold示例中使用此插件(index.js):

example of use this plugin in a hellowold example (index.js):

var app = {
    // Application Constructor
    initialize: function() {
        this.bindEvents();
    },
    // Bind Event Listeners
    //
    // Bind any events that are required on startup. Common events are:
    // 'load', 'deviceready', 'offline', and 'online'.
    bindEvents: function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);
    },
    // deviceready Event Handler
    //
    // The scope of 'this' is the event. In order to call the 'receivedEvent'
    // function, we must explicitly call 'app.receivedEvent(...);'
    onDeviceReady: function() {
        app.receivedEvent('deviceready');
    },
    // Update DOM on a Received Event
    receivedEvent: function(id) {
        var parentElement = document.getElementById(id);
        var listeningElement = parentElement.querySelector('.listening');
        var receivedElement = parentElement.querySelector('.received');

        listeningElement.setAttribute('style', 'display:none;');
        receivedElement.setAttribute('style', 'display:block;');

        console.log('Received Event: ' + id);

        hockeyapp.start(
            function() { alert('hockeyapp initialised'); },
            function(msg) { alert(msg); },
            '< your APP ID >');

        hockeyapp.saveException(
            function() { alert('hockeyapp saveException'); },
            function(msg) { alert(msg); },
            'Something wrong has happened: bla bla bla...');    
    }
};

app.initialize();

曲棍球将这些受控制的异常存储在应用程序的文件目录中,并要求在下次用户时发送打开应用程序:

Hockey stores these controlled exceptions in the file directory of the app and asks to send it the next time user opens app:

这篇关于如何将Hockey App与Hybrid移动应用程序集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆