Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
{
"locator": "https://github.com/WizardFactory/cordova-plugin-todayweather-config.git",
"id": "cordova-plugin-todayweather-config"
}
},
"cordova-plugin-apple-watch"
],
"cordovaPlatforms": [
{
Expand Down
1 change: 1 addition & 0 deletions client/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<script src="js/controller.settingctrl.js"></script>
<script src="js/controller.tabctrl.js"></script>
<script src="js/controller.purchase.js"></script>
<script src="js/controller.watch.js"></script>
<script src="js/service.twads.js"></script>
<script src="js/service.weatherinfo.js"></script>
<script src="js/service.weatherutil.js"></script>
Expand Down
1 change: 1 addition & 0 deletions client/www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ angular.module('starter', [
'controller.settingctrl',
'controller.guidectrl',
'controller.purchase',
'controller.watch',
'controller.units',
'controller.start',
'service.run'
Expand Down
39 changes: 39 additions & 0 deletions client/www/js/controller.watch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Created by aleckim on 2017. 10. 24..
* https://github.com/DVenkatesh/cordova-plugin-watchconnectivity
*/

angular.module('controller.watch', []).factory('Watch', function () {
var obj = {};
obj.appGroupId;

obj.sendUserDefaults = function (obj, callback) {
if (!this.appGroupId) {
return callback(new Error("App group id is null"));
}

applewatch.sendUserDefaults(function () {
callback();
},
function () {
callback(new Error("Fail to send user defaults"));
},
obj, this.appGroupId);
};

obj.init = function (appGroupId) {
var that = this;
if(window.applewatch == undefined) {
console.log("Fail to load applewatch");
return;
}
applewatch.init(function (id) {
that.appGroupId = id;
console.log('applewatch is initialized group id='+id);
}, function () {
console.log('applewatch fail to init');
}, appGroupId);
};

return obj;
});
6 changes: 5 additions & 1 deletion client/www/js/service.run.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
angular.module('service.run', [])
.run(function($rootScope, $ionicPlatform, WeatherInfo, Util) {
.run(function($rootScope, $ionicPlatform, WeatherInfo, Util, Watch) {
//위치 재조정해야 함.
if (twClientConfig.debug) {
Util.ga.debugMode();
Expand Down Expand Up @@ -102,6 +102,10 @@ angular.module('service.run', [])
Util.ga.trackEvent('app', 'status', 'pause');
}, false);

if (ionic.Platform.isIOS()) {
Watch.init(Util.suiteName);
}

WeatherInfo.loadCities();
WeatherInfo.loadTowns();
$ionicPlatform.on('resume', function(){
Expand Down
10 changes: 9 additions & 1 deletion client/www/js/service.weatherinfo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
angular.module('service.weatherinfo', [])
.factory('WeatherInfo', function ($rootScope, WeatherUtil, Util) {
.factory('WeatherInfo', function ($rootScope, WeatherUtil, Util, Watch) {
var cities = [];
var cityIndex = -1;
var obj = {
Expand Down Expand Up @@ -295,6 +295,14 @@ angular.module('service.weatherinfo', [])
Util.ga.trackEvent('plugin', 'error', 'saveAppPreferences');
Util.ga.trackException(error, false);
}, 'cityList', JSON.stringify(pList));

if (ionic.Platform.isIOS()) {
Watch.sendUserDefaults(pList, function (err) {
if (err) {
Util.ga.trackEvent('watch', 'error', 'sendUserDefaults');
}
});
}
};

obj._loadCitiesPreference = function (callback) {
Expand Down