# Possible? publicly hosted mobile apps using my own mpns

**URL:** <https://forum.mattermost.com/t/possible-publicly-hosted-mobile-apps-using-my-own-mpns/3383>\
**Category:** Troubleshooting\
**Created:** [June 9, 2017, 12:38pm UTC](https://forum.mattermost.com/t/possible-publicly-hosted-mobile-apps-using-my-own-mpns/3383 "2017-06-09T12:38:54Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![COOLmoeD](https://avatars.discourse-cdn.com/v4/letter/c/c77e96/32.png) [@COOLmoeD](https://forum.mattermost.com/u/COOLmoeD)\
**Post date:** [June 9, 2017, 12:38pm UTC](https://forum.mattermost.com/t/possible-publicly-hosted-mobile-apps-using-my-own-mpns/3383/1 "2017-06-09T12:38:54Z")

</div>

Hello,  
I take care of a small mattermost server instance for the company I work for. We have no subscription and are using the plain Team Edition(thanks for that to the devs and everyone else involved, it’s just great).  
My supervisors now want push notifications(for android and iOS) so bad that I started some research.

[https://docs.mattermost.com/deployment/push.html#securing-mobile-deployments](https://docs.mattermost.com/deployment/push.html#securing-mobile-deployments)  
states that:  
- If you use the publicly hosted mobile apps in iTunes or Google Play, you need to use the publicly hosted MPNS from Mattermost, Inc., which uses the corresponding secret.  
- If you use a privately-hosted mobile app in an Enterprise App Store by compiling your own app, you need to also compile and use your own MPNS with the corresponding secret.

Does this mean:  
The only way NOT to use the publicy hosted MPNS from mattermost is to be in the apple enterprise developer program(that goes for iOS) in order to aqquire “in house and ad hoc” disitrbution certificates?

Is there any way how to enable mobile push notifications using a private push notification server without being in the apple enterprise developer program?

Anyone got any experience with that? Any help is much appreciated!

Cheers,  
CoolMoeD

---

<div class="post-metadata">

**Author:** ![elias](https://avatars.discourse-cdn.com/v4/letter/e/41988e/32.png) [@elias](https://forum.mattermost.com/u/elias)\
**Post date:** [June 12, 2017, 1:38pm UTC](https://forum.mattermost.com/t/possible-publicly-hosted-mobile-apps-using-my-own-mpns/3383/2 "2017-06-12T13:38:03Z")

</div>

Hi @COOLmoeD,

So to enable push notifications you will definitely need the certificates that apple give you for in-house, ad-hoc, development, production, etc… just to be able to send push notifications to IOS devices that’s the way it is, also you’ll need an ID from GCM or FCM as well for Android devices and then you can use [Mattermost Push Proxy](https://github.com/mattermost/mattermost-push-proxy) to connect your MM instance to it and get the notifications.

---

<div class="post-metadata">

**Author:** ![COOLmoeD](https://avatars.discourse-cdn.com/v4/letter/c/c77e96/32.png) [@COOLmoeD](https://forum.mattermost.com/u/COOLmoeD)\
**Post date:** [June 13, 2017, 6:46am UTC](https://forum.mattermost.com/t/possible-publicly-hosted-mobile-apps-using-my-own-mpns/3383/3 "2017-06-13T06:46:20Z")

</div>

Hey @elias,  
First of all, thanks for taking your time to write an answer to my question. Let me add some information regarding my background: I have more of a technical background working with linux servers in general, I have very little knowledge of app development and/or distribution via appstore/playstore.

The company I work for is a member of the Apple Developer Program, but sadly not of the Apple Developer Enterprise Program.  
So in the Apple Developer Program I could create:  
Development Certs

- iOSApp Development
- Apple Push Notification service SSL(sandbox)  
Production Certs
- App Store and Ad Hoc
- Apple Push Notification Service SSL (Sandbox & Production)
- and some more which are not related to Push Notifications

so the Option for “In House and Adhoc” Certificates under Production is missing.

Is there a workaround by just using the Development Push Notification Cert? And for example distributing the app in “development” to the users via TestFlight(there should be a similiar app in the goole playstore I guess, didn’t research on that though)?  
Would this be in agreement with the MIT License Mattmost Team Edition is published under?

What do you think?

Cheers,  
CoolMoeD

---

<div class="post-metadata">

**Author:** ![elias](https://avatars.discourse-cdn.com/v4/letter/e/41988e/32.png) [@elias](https://forum.mattermost.com/u/elias)\
**Post date:** [June 13, 2017, 12:31pm UTC](https://forum.mattermost.com/t/possible-publicly-hosted-mobile-apps-using-my-own-mpns/3383/4 "2017-06-13T12:31:32Z")

</div>

Hey @COOLmoeD,

There is no explicit option for “In House and Adhoc” in the Apple Developer Program hehe sorry for that, the Production certs fro “Apple Push Notification service SSL” is the one you want. Be aware that you are going to need to modify the App in XCode to match your bundleId before you distribute it in any way, the same goes for the Android app and yes that would be in agreement with the license.

---

<div class="post-metadata">

**Author:** ![COOLmoeD](https://avatars.discourse-cdn.com/v4/letter/c/c77e96/32.png) [@COOLmoeD](https://forum.mattermost.com/u/COOLmoeD)\
**Post date:** [June 14, 2017, 6:00am UTC](https://forum.mattermost.com/t/possible-publicly-hosted-mobile-apps-using-my-own-mpns/3383/5 "2017-06-14T06:00:14Z")

</div>

Hey @elias,  
So it looks like I just got scared off early. When following the first link under [Obtaining Apple Developer Keys](https://github.com/mattermost/mattermost-push-proxy) to [developer.apple.com](https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/DistributingEnterpriseProgramApps/DistributingEnterpriseProgramApps.html#//apple_ref/doc/uid/TP40012582-CH33-SW4) the screenshot shows the Option “In House and Adhoc” under Production. So I guess the documentation on the apple site is outdated.  
I will start working with the Production cert for “Apple Push Notification service SSL” as you advised now.

Let’s see how far I get 🙂

I might revive this thread at any time when I run into problems related to the title of the topic 🙂

Thanks again for you feedback!

---

<div class="post-metadata">

**Author:** ![COOLmoeD](https://avatars.discourse-cdn.com/v4/letter/c/c77e96/32.png) [@COOLmoeD](https://forum.mattermost.com/u/COOLmoeD)\
**Post date:** [June 28, 2017, 12:48pm UTC](https://forum.mattermost.com/t/possible-publicly-hosted-mobile-apps-using-my-own-mpns/3383/6 "2017-06-28T12:48:44Z")

</div>

Hey Elias,  
not sure if you’re still following this thread, if not, maybe someone else has an idea what I’m doing wrong.

I had a few problems with the Apple keys in the mattermost-push-proxy.json

```
2017/06/26 11:04:37 CRIT Failed to load the apple pem cert err=open ../config/aps_production_priv.pem: no such file or directory for type=apple
panic: Failed to load the apple pem cert err=open ../config/aps_production_priv.pem: no such file or directory for type=apple

```

tried that with relative and absolute paths, no success, the files are there, permissions are 0664 for the appropriate user, which is not “ubuntu” but a custom user which is allowed to “sudo su”.  
so I decided to kick out that section and make android work first and then get back to iOS.

I’m struggling getting it to work with FCM after I completely kicked out the Apple Section in the ./config/mattermost-push-proxy.json  
Now I’m wondering if I should use FCM or GCM.  
After many failures I’m wondering if it might be easier to get it work with GCM instead of FCM. In AndroidStudio I can see a lot of java code in the source of the mattermost android app related to GCM, nothing about FCM. So it might be the case that I’d have to change “a lot of the”/“some” java code for getting it to work via FCM?

So right now I can’t even verify that the server is working through a local test.  
I tried this with FCM SenderID and FCM Server Key as AndroidApiKey as I found different statements regarding what the AndroidApiKey actually is 😕

Test with FCM SenderID as AndroidApiKey in …/config/mattermost-push-proxy.json

`curl http://127.0.0.1:8066/api/v1/send_push -X POST -H "Content-Type: application/json" -d '{ "message":"test", "badge": 1, "platform":"android", "server_id":"(MY_SERVER_ID)", "device_id":"(MY_DEVICE_ID)"}'`  
I get  
`{"error":"unknown transport error","status":"FAIL"}`  
and from /var/log/upstart/mattermost-push-proxy.log

> ```
> 2017/06/27 09:46:12 INFO Sending android push notification for type=android
> 2017/06/27 09:46:12 ERROR Failed to send GCM push sid=(MY_SERVER_ID) did=(MY_ANDROID_DEVICE_ID) err=401 error: 401 Unauthorized type=android
> 
> ```

Test with FCM Server Key as AndroidApiKey in …/config/mattermost-push-proxy.json

same curl like above outputs:  
`{"status":"REMOVE"}`  
and from /var/log/upstart/mattermost-push-proxy.log

> ```
> 2017/06/28 14:35:17 INFO Sending android push notification for type=android
> 2017/06/28 14:35:18 INFO Android response failure sending remove code: (Cryptic_numbers) 0 1 0 [{ InvalidRegistration}]} type=android
> 
> ```

any ideas? anyone ? 😕

---

<div class="post-metadata">

**Author:** ![elias](https://avatars.discourse-cdn.com/v4/letter/e/41988e/32.png) [@elias](https://forum.mattermost.com/u/elias)\
**Post date:** [July 3, 2017, 9:17pm UTC](https://forum.mattermost.com/t/possible-publicly-hosted-mobile-apps-using-my-own-mpns/3383/7 "2017-07-03T21:17:15Z")

</div>

Are you running mattermost-push-proxy from the folder that contains `config/aps_production_priv.pem` ?

this is my config

```auto
{
	"ListenAddress":":8066",
	"ThrottlePerSec":300,
	"ThrottleMemoryStoreSize":50000,
	"ThrottleVaryByHeader":"X-Forwarded-For",
  "EnableMetrics": false,
	"ApplePushSettings": [
		{
			"Type" : "apple_rn",
			"ApplePushUseDevelopment": false,
			"ApplePushCertPrivate": "./config/aps_production_priv.pem",
			"ApplePushCertPassword": "",
			"ApplePushTopic": "com.mattermost.react.native"
		}
	],
	"AndroidPushSettings": [
		{
			"Type" : "android_rn",
			"AndroidApiKey": "XXXXXXXXXXXXXXXXXXX"
		}
	]
}

```

for the AndroidApiKey i’m attaching the Firebase console settings and the one that you need to use is the Web API Key  
 ![](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex020/uploads/mattermost/original/2X/7/74c2445cab958e7787219cd6515efc167c5b30df.png)

---

<div class="post-metadata">

**Author:** ![COOLmoeD](https://avatars.discourse-cdn.com/v4/letter/c/c77e96/32.png) [@COOLmoeD](https://forum.mattermost.com/u/COOLmoeD)\
**Post date:** [July 4, 2017, 8:47am UTC](https://forum.mattermost.com/t/possible-publicly-hosted-mobile-apps-using-my-own-mpns/3383/8 "2017-07-04T08:47:23Z")

</div>

Hey Elias,  
I was really confident that I’ll get at least the android app running today when I read your post this morning, sadly I’m still stuck.  
Yes I am running mattermost-push-proxy from the folder that contains config/aps\_production\_priv.pem  
The main folder is /home/user/mattermost-push-proxy

```
ls -lha /home/user/mattermost-push-proxy/config
drwxrwxr-x 2 user user 4.0K Jul 4 09:13 .
drwxrwxr-x 5 user user 4.0K Jun 26 11:38 ..
-rw-rw-r-- 1 user user 2.2K Jun 23 16:48 aps_production.pem
-rw-rw-r-- 1 user user 1.8K Jun 23 16:48 aps_production_priv.pem
-rw-rw-r-- 1 user user 6 Apr 27 21:33 build.txt
-rw-rw-r-- 1 user user 440 Jul 4 09:08 mattermost-push-proxy.json

```

my mattermost-push-proxy.json looks like this(after I updated the AndroidApiKey value):

```
{
   "ListenAddress":":8066",
    "ThrottlePerSec":300,
    "ThrottleMemoryStoreSize":50000,
    "ThrottleVaryByHeader":"X-Forwarded-For",
    "EnableMetrics": false,
    "AndroidPushSettings":[
        {
            "Type":"android",
            "AndroidApiKey":"AIzaSyD(OBSCURED)"
        },
        {
            "Type":"android_rn",
            "AndroidApiKey":"AIzaSyD(OBSCURED)"
        }
    ]
}

```

and a screenshot from the firebase console

 ![](https://us1.discourse-cdn.com/flex020/uploads/mattermost/original/2X/5/529c1aaa3018406940c345ffe7463a436c1ffba9.jpg)

I also verified MY\_SERVER\_ID again  
`( SELECT * FROM Systems WHERE Name = 'DiagnosticId';` )  
and rebuilt the app, installed it on my mobile and updated the curl command execution to the new MY\_DEVICE\_ID  
`(SELECT Email, DeviceId FROM Sessions, Users WHERE Sessions.UserId = Users.Id AND DeviceId != '' AND Email = 'my_email_address'; )`

I restarted the mattermost-push-proxy afterwards. sadly, still the same “unauthorized” error:

` curl http://127.0.0.1:8066/api/v1/send_push -X POST -H "Content-Type: application/json" -d '{ "message":"test", "badge": 1, "platform":"android", "server_id":"(MY_SERVER_ID)", "device_id":"(MY_DEVICE_ID)"}'`

```
output {"error":"unknown transport error","status":"FAIL"}

```

output from /var/log/upstart/mattermost-push-proxy.log

> 2017/07/04 09:41:04 INFO Loading /home/user/mattermost-push-proxy/config/mattermost-push-proxy.json  
> 2017/07/04 09:41:04 INFO Push proxy server is initializing…  
> 2017/07/04 09:41:04 INFO Initializing Android notificaiton server for type=android  
> 2017/07/04 09:41:04 INFO Initializing Android notificaiton server for type=android\_rn  
> 2017/07/04 09:41:04 INFO Server is listening on :8066  
> 2017/07/04 09:41:09 INFO Sending android push notification for type=android  
> 2017/07/04 09:41:10 ERROR Failed to send GCM push sid=(MY\_SERVER\_ID) did=(MY\_DEVICE\_ID) err=401 error: 401 Unauthorized type=android

If you have any other ideas how to debug this I’d appreciate every hint. and no matter if or if not, thank you for the time you have invested into helping me so far !!!

Cheers,  
CoolMoeD

---

<div class="post-metadata">

**Author:** ![elias](https://avatars.discourse-cdn.com/v4/letter/e/41988e/32.png) [@elias](https://forum.mattermost.com/u/elias)\
**Post date:** [July 6, 2017, 2:47pm UTC](https://forum.mattermost.com/t/possible-publicly-hosted-mobile-apps-using-my-own-mpns/3383/9 "2017-07-06T14:47:18Z")

</div>

Hi @COOLmoeD

not really sure what’s going on here really, it seems that GCM is not validating your key or something like that, just to be sure, that deviceId is registered in GCM?

---

<div class="post-metadata">

**Author:** ![COOLmoeD](https://avatars.discourse-cdn.com/v4/letter/c/c77e96/32.png) [@COOLmoeD](https://forum.mattermost.com/u/COOLmoeD)\
**Post date:** [July 7, 2017, 8:28am UTC](https://forum.mattermost.com/t/possible-publicly-hosted-mobile-apps-using-my-own-mpns/3383/10 "2017-07-07T08:28:35Z")

</div>

Hey @elias  
Me not being sure why the device should be registered in gcm instead of fcm shows one more time that I have ~0.1% knowledge when it comes to mobile app developement.  
I will have to learn some basics first I guess and stop asking beginner questions here.  
I will keep on struggling, once I find out what I’m actually doing wrong here, I will upgrade this thread.

Thanks again for the time you invested trying to figure out what I’m doing wrong(might just be too many things)!

Take care,  
CoolMoeD

---

<div class="post-metadata">

**Author:** ![lindy65](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/lindy65/32/1811_2.png) [@lindy65](https://forum.mattermost.com/u/lindy65)\
**Post date:** [July 13, 2017, 8:55am UTC](https://forum.mattermost.com/t/possible-publicly-hosted-mobile-apps-using-my-own-mpns/3383/11 "2017-07-13T08:55:07Z")

</div>

Thanks @COOLmoeD,

I’ll close this issue off for now but feel free to come back at any time to report issues or ask for help 🙂

---

<div class="post-metadata">

**Author:** ![vipinbimt](https://avatars.discourse-cdn.com/v4/letter/v/a3d4f5/32.png) [@vipinbimt](https://forum.mattermost.com/u/vipinbimt)\
**Post date:** [August 11, 2017, 1:07pm UTC](https://forum.mattermost.com/t/possible-publicly-hosted-mobile-apps-using-my-own-mpns/3383/12 "2017-08-11T13:07:43Z")

</div>

please update your solution

---

<div class="post-metadata">

**Author:** ![COOLmoeD](https://avatars.discourse-cdn.com/v4/letter/c/c77e96/32.png) [@COOLmoeD](https://forum.mattermost.com/u/COOLmoeD)\
**Post date:** [August 15, 2017, 7:02am UTC](https://forum.mattermost.com/t/possible-publicly-hosted-mobile-apps-using-my-own-mpns/3383/13 "2017-08-15T07:02:40Z")

</div>

hey @vipinbimt  
sadly I was not able to solve this. My plan was to start again from scratch with the release of the new mobile app.  
As the new mobile app is out, I was not able to find an updated doc , check [https://docs.mattermost.com/deployment/push.html](https://docs.mattermost.com/deployment/push.html)

I have my doubts that I will ever be able to solve this as I have very little knowledge about app development. As I said earlier in this post, I’m pretty much a server admin and not a developer. Though getting a sample push notification project working in Firebase was no problem at all for me…

If I solve this, I will update this post and write down a detailed step by step tutorial for non app developers. But yes, I have my doubts.

Cheers,  
CoolMoeD

while at it:  
did anyone already compile the new react native mobile app for usage with self hosted mpns? I just downloaded and compiled it from here [https://github.com/mattermost/mattermost-mobile](https://github.com/mattermost/mattermost-mobile) . but logo still says beta and I couldn’t find instructions where to enter gcm sender id, server url and so on.

---

<div class="post-metadata">

**Author:** ![wannabe](https://avatars.discourse-cdn.com/v4/letter/w/bbe5ce/32.png) [@wannabe](https://forum.mattermost.com/u/wannabe)\
**Post date:** [September 14, 2017, 10:42am UTC](https://forum.mattermost.com/t/possible-publicly-hosted-mobile-apps-using-my-own-mpns/3383/14 "2017-09-14T10:42:27Z")

</div>

> while at it:  
> did anyone already compile the new react native mobile app for usage with self hosted mpns? I just downloaded and compiled it from here [https://github.com/mattermost/mattermost-mobile2](https://github.com/mattermost/mattermost-mobile2) . but logo still says beta and I couldn’t find instructions where to enter gcm sender id, server url and so on.

I have compiled. But only for Android.  
Find file “mattermost-mobile/android/app/src/main/AndroidManifest.xml” and change `<meta-data android:name="com.wix.reactnativenotifications.gcmSenderId" android:value="<VALUE_TO_CHANGE>\0"/>`.  
That’s all you need.

---

<div class="post-metadata">

**Author:** ![stephanfriedrich](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/stephanfriedrich/32/1871_2.png) [@stephanfriedrich](https://forum.mattermost.com/u/stephanfriedrich)\
**Post date:** [December 9, 2017, 10:12am UTC](https://forum.mattermost.com/t/possible-publicly-hosted-mobile-apps-using-my-own-mpns/3383/15 "2017-12-09T10:12:38Z")

</div>

@lindy65 why are you closing these ticket, its not solved yet ?!  
whats your declaration for this?

---

<div class="post-metadata">

**Author:** ![stephanfriedrich](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/stephanfriedrich/32/1871_2.png) [@stephanfriedrich](https://forum.mattermost.com/u/stephanfriedrich)\
**Post date:** [December 9, 2017, 10:21am UTC](https://forum.mattermost.com/t/possible-publicly-hosted-mobile-apps-using-my-own-mpns/3383/16 "2017-12-09T10:21:29Z")

</div>

@COOLmoeD actually i try to run push-notifications with mattermost.  
now installed mattermost-server and mattermost-push-proxy and try to test it with mattermost-origin android -app but got the same issue.

```auto
same curl like above outputs:
{"status":"REMOVE"}

```

if i red the documentation correctly, so we have to build the mattermot-app by your own .  
currently did not tried it

---

<div class="post-metadata">

**Author:** ![lindy65](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/lindy65/32/1811_2.png) [@lindy65](https://forum.mattermost.com/u/lindy65)\
**Post date:** [December 9, 2017, 8:34pm UTC](https://forum.mattermost.com/t/possible-publicly-hosted-mobile-apps-using-my-own-mpns/3383/17 "2017-12-09T20:34:58Z")

</div>

Hey @stephanfriedrich,

Apologies, from your message above mine (where I mentioned I’d close off the issue), it seemed you wouldn’t be actively working on this and that you’d come back with questions when and if needed so I closed it off in the meantime.

I’ve taken off the ‘solved’ label 🙂

---

<div class="post-metadata">

**Author:** ![COOLmoeD](https://avatars.discourse-cdn.com/v4/letter/c/c77e96/32.png) [@COOLmoeD](https://forum.mattermost.com/u/COOLmoeD)\
**Post date:** [December 11, 2017, 9:46am UTC](https://forum.mattermost.com/t/possible-publicly-hosted-mobile-apps-using-my-own-mpns/3383/18 "2017-12-11T09:46:55Z")

</div>

Hey @stephanfriedrich ,  
As far as I understand: Yes, you will have to build the mattermost apps on your own.  
If you need help with setting everything up, I can recommend joining the mattermost nightly build chat server.  
Everyone in this chat server is very helpful and dedicated, give it a try if you didn’t yet!  
[Mattermost Nightly Build Server](https://pre-release.mattermost.com)

You will need basic app development knowledge though(if you’re used to working with IntelliJ / AndroidStudio you won’t have any problems).

I did some great improvements when it comes to app development: I got the dev environment set up on a Mac for iOS and android. 🙂 I wasn’t able though to succesfully test sending out push notifcations via the MPNS.  
Thanks to elias (I can only mention 2 users in a post, as I’m a new user, otherwise I’d mention him here.) for providing a work in progress tutorial regarding the setup of the dev environment for both iOS and android!!

I am currently working on a centralized logging server and the year is short, so I do not know if I can start working on the push notifcation again this year. But however: I got “working mattermost push notifications via MPNS” as a objective for Q1 2018. And I’m confident that I will achieve that goal.

@lindy65 closnig this post with “solved” was ok for me, as I honestly gave up on it as written above. But I guess you know that 🙂

Cheers
