#功能说明:第三方应用或web下载/唤醒/自动登录到学习通
#负责人:iOS-肖泽强, android-殷雅乐
#协议版本:v1.0
协议详细操作过程
1.第三方应用内上架学习通
2.第三方应用后台服务配置
3.第三方应用用户账号对接学习通泛雅后台
4.第三方应用内打开学习通完成自动登录调用方式:
step2配置参数说明: fid 单位id 超星固定分配 如:2023fidType 单位类型 超星固定分配 如:1token 用户登录名(工号、学号)加密信息DES(KEY对接时沟通)
代码示例:
Android
学习通包名:com.chaoxing.mobile
/**
* 判断是否已经安装学习通
*
* @param context
* @param packageName 学习通包名
* @return
*/public static boolean isAppInstalled(Context context, String packageName) { try { return context.getPackageManager().getPackageInfo(packageName, 0) != null;
} catch (PackageManager.NameNotFoundException e) {
} return false;
}/**
* 启动学习通(仅用作唤醒学习通)
*
* @param context
* @param packageName 学习通包名
*/public static void launchStudy(Context context, String packageName) {
Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName); if (intent != null) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
}/**
* @param context 启动学习通并登录
* @param url 登录url(如:cxstudy://cxstudy/login?fid=xxx&fidType=xxx&token=xxx)
*/public static void launchStudyAndSignIn(Context context, String url) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}// WEB启动学习通(方式1)function launchStudy() { window.location = "cxstudy://";
setTimeout(function() { if (!document.webkitHidden) { window.location = 'https://apps.chaoxing.com/';
}
}, 50);
}// WEB启动学习通(方式2)function launchStudy2() { window.location = 'intent://lanuch#Intent;scheme=cxstudy;package=com.chaoxing.mobile;S.browser_fallback_url=https%3A%2F%2Fapp.chaoxing.com;end;';
}// WEB启动学习通并登录(方式1)function launchStudyAndSignIn() { window.location = "cxstudy://cxstudy/login?fid=xxx&fidType=xxx&token=xxx";
setTimeout(function() { if (!document.webkitHidden) { window.location = 'https://apps.chaoxing.com/';
}
}, 50);
}// WEB启动学习通并登录(方式2)function launchStudyAndSignIn2() { window.location = 'intent://cxstudy/login?fid=xxx&fidType=xxx&token=xxx#Intent;scheme=cxstudy;package=com.chaoxing.mobile;S.browser_fallback_url=https%3A%2F%2Fapp.chaoxing.com;end;';
}iOS
/**
* @note canOpenURL 正常调用需在 info.plist中找到LSApplicationQueriesSchemes,添加对应key "cxstudy"
* @param appOpenURLStr 为唤醒地址 仅唤醒而不登录可赋值@"cxstudy://"
* @param appDownloadURLStr 为学习通App Store中的下载地址
*/if ( [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"cxstudy://"]]) { NSString *appOpenURLStr = @"cxstudy://cxstudy/login?fid=xxx&fidType=xxx&token=xxx";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:appOpenURLStr]];
}else { NSString *appDownloadURLStr = @"https://itunes.apple.com/cn/app/%E8%B6%85%E6%98%9F%E5%AD%A6%E4%B9%A0%E9%80%9A/id977946724?mt=8";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: appDownloadURLStr]];
}
作者:ceremony08
链接:https://www.jianshu.com/p/da548bb38392
點擊查看更多內(nèi)容
為 TA 點贊
評論
評論
共同學習,寫下你的評論
評論加載中...
作者其他優(yōu)質(zhì)文章
正在加載中
感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦