从基于事件源的通知迁移推送通知

improve this page | report issue


概述

从 IBM Mobile Foundation V8.0 起,基于事件源的模型将不受支持,并且完全由推送服务模型启用推送通知功能。 要将 MobileFirst 先前版本上基于事件源的现有应用程序移至 V8.0,必须将其迁移到新的推送服务模型。

迁移期间,请谨记,这并不是要用一个 API 代替另一个 API,更多的是使用一种模型/方法代替另一种模型/方法。

例如,在基于事件源的模型中,如果要对移动应用程序用户进行分段,从而向特定分段发送通知,那么会将每个分段作为不同事件源进行建模。 在推送服务模型中,将通过定义表示分段的标记并使用户预订各自的标记来实现相同目的。 基于标记的通知将替代基于事件源的通知。

跳至:


下表为您提供两种模型之间的比较。

用户需求 事件源模型 推送服务模型
为应用程序启用推送通知
  • 创建事件源适配器并在其中创建 EventSource。
  • 使用推送凭证配置或设置应用程序。
使用推送凭证配置或设置应用程序。
为移动客户端应用程序启用推送通知
  • 创建 WLClient
  • 连接到 MobileFirst Server
  • 获取推送客户机实例
  • 预订事件源
  • 实例化推送客户机
  • 初始化推送客户机
  • 注册移动设备
要为移动式客户机应用程序启用基于特定标记的通知 不受支持。 预订相关标记(使用标记名称)。
在移动式客户机应用程序中接收并处理通知 注册侦听器实施。 注册侦听器实施。
将推送通知发送到移动式客户机应用程序
  • 实现用于在内部调用 WL.Server API 来发送推送通知的适配器过程。
  • WL 服务器 API 提供发送通知的方式:
    • 按用户
    • 按设备
    • 广播(所有设备)
  • 然后,后端服务器应用程序可以调用适配器过程,以触发作为其应用程序逻辑中的一部分的推送通知。
  • 后端服务器应用程序可以直接调用消息 REST API。 但是,这些应用程序必须作为机密客户机向 MobileFirst Server 注册,并获取必须在 REST API 的授权头中传递的有效 OAuth 访问令牌。
  • REST API 提供用于发送通知的选项:
    • 按用户
    • 按设备
    • 按平台
    • 按标记
    • 广播(所有设备)
要按定期时间段(轮询时间间隔)触发推送通知 实现用于在事件源适配器内发送推送通知的函数,并将其作为 createEventSource 函数调用的一部分。 不受支持。
使用名称、URL 和事件类型注册挂钩。 在预订或取消预订推送通知的设备的路径上实现挂钩。 不受支持。

迁移方案

从 Mobile Foundation V8.0 开始,将不支持基于事件源的模型,并且在 Mobile Foundation 上完全由推送服务模型启用推送通知功能,该模型是事件源模型的更简单且灵活的替代方法。

IBM MobileFirst Platform Foundation 先前版本上基于事件源的现有应用程序需要迁移到 V8.0,从而迁移到新的推送服务模型。

跳转到相关部分

混合应用程序

迁移方案示例包括使用单一事件源或多个源、广播或者单点广播通知或标签通知的应用程序。

方案 1:现有应用程序在其应用中使用单个事件源

应用程序已在 MobileFirst 的较早版本上使用单个事件源,因为它仅通过基于事件源的模型支持推送。

客户机

要在 V8.0.0 中对此进行迁移,请将此模型转换为单点广播通知。

  1. 初始化应用程序中的 MobileFirst 推送客户机实例,并在成功回调中注册应接收通知的回调方法。

    MFPPush.initialize(function(successResponse){
    MFPPush.registerNotificationsCallback(notificationReceived); },
    function(failureResponse){alert("Failed to initialize");    
                               }  
    );
    
  2. 实施通知回调方法。

    var notificationReceived = function(message) {
         alert(JSON.stringify(message));
    };
    
  3. 向推送通知服务注册移动设备。

    MFPPush.registerDevice(function(successResponse) {
         alert("Successfully registered");
         },
       function(failureResponse) {
         alert("Failed to register");
         }
    );
    
  4. (可选)从推送通知服务注销移动设备。

    MFPPush.unregisterDevice(function(successResponse) {
         alert("Successfully unregistered");
         },
       function(failureResponse) {
         alert("Failed to unregister");
         }
    );
    
  5. 除去 WL.Client.Push.isPushSupported()(如果已使用)并使用:

    MFPPush.isPushSupported (function(successResponse) {
         alert(successResponse);
        },
        function(failureResponse) {
            alert("Failed to get the push suport status");
        }
    );
    
  6. 除去以下 WL.Client.Push API,因为将没有要预订并用于注册通知回调的事件源。

    • registerEventSourceCallback()
    • subscribe()
    • unsubscribe()
    • isSubscribed()
    • onReadyToSubscribe()
服务器
  1. 除去适配器中的以下 WL.Server API(如果已使用):
    • notifyAllDevices()
    • notifyDevice()
    • notifyDeviceSubscription()
    • createEventSource()
  2. 针对使用同一事件源的每个应用程序完成以下步骤:
    1. 使用 MobileFirst Operations Console 设置凭证。 请参阅配置推送通知设置

      您还可以对 Android 应用程序使用更新 GCM 设置 (PUT) REST API 来设置凭证,或者对 iOS 应用程序使用更新 APN 设置 (PUT) REST API 来设置凭证。

    2. 作用域元素映射中添加作用域 push.mobileclient
    3. 创建标记以支持将推送通知发送至订户。 请参阅“为推送通知定义标记”。
    4. 您可以使用以下任一方法来发送通知:

方案 2:现有应用程序在其应用中使用多个事件源

使用多个事件源的应用程序要求基于预订对用户进行细分。

客户机

这将映射到基于相关主题对用户/设备进行分段的标记。 要对此进行迁移,可以将此模型转换为基于标记的通知。

  1. 初始化应用程序中的 MFPPush 客户机实例,并在成功回调中注册应接收通 知的回调方法。

    MFPPush.initialize(function(successResponse){
         MFPPush.registerNotificationsCallback(notificationReceived);              					},
         function(failureResponse){
             alert("Failed to initialize");
         }
    );
    
  2. 实施通知回调方法。

    var notificationReceived = function(message) {
         alert(JSON.stringify(message));
    };
    
  3. 向推送通知服务注册移动设备。

    MFPPush.registerDevice(function(successResponse) {
         alert("Successfully registered");
         },
       function(failureResponse) {
         alert("Failed to register");
         }
    );
    
  4. (可选)从推送通知服务注销移动设备。

    MFPPush.unregisterDevice(function(successResponse) {
         alert("Successfully unregistered");
         },
       function(failureResponse) {
         alert("Failed to unregister");
         }
    );
    
  5. 除去 WL.Client.Push.isPushSupported()(如果已使用)并使用。

    MFPPush.isPushSupported (function(successResponse) {
         alert(successResponse);
         },
       function(failureResponse) {
         alert("Failed to get the push suport status");
         }
    );
    
  6. 除去以下 WL.Client.Push API,因为将没有要预订并用于注册通知回调的事件源。
    • registerEventSourceCallback()
    • subscribe()
    • unsubscribe()
    • isSubscribed()
    • onReadyToSubscribe()
  7. 预订标记。

    var tags = ['sample-tag1','sample-tag2'];
    MFPPush.subscribe(tags, function(successResponse) {
     	alert("Successfully subscribed");
         },
       function(failureResponse) {
     	alert("Failed to subscribe");
         }
    );
    
  8. (可选)从标记取消预订。

    MFPPush.unsubscribe(tags, function(successResponse) {
         alert("Successfully unsubscribed");
         },
       function(failureResponse) {
         alert("Failed to unsubscribe");
         }
    );
    
服务器

除去适配器中的以下 WL.Server API(如果已使用):

  • notifyAllDevices()
  • notifyDevice()
  • notifyDeviceSubscription()
  • createEventSource()

针对使用同一事件源的每个应用程序完成以下步骤:

  1. 使用 MobileFirst Operations Console 设置凭证。 请参阅配置推送通知设置

    您还可以对 Android 应用程序使用更新 GCM 设置 (PUT) REST API 来设置凭证,或者对 iOS 应用程序使用更新 APN 设置 (PUT) REST API 来设置凭证。

  2. 作用域元素映射中添加作用域 push.mobileclient
  3. 创建标记以支持将推送通知发送至订户。 请参阅“为推送通知定义标记”。
  4. 您可以使用以下任一方法来发送通知:

方案 3:现有应用程序在其应用中使用广播/单点广播通知

客户机
  1. 初始化应用程序中的 MFPPush 客户机实例,并在成功回调中注册应接收通 知的回调方法。

    MFPPush.initialize(function(successResponse){
         MFPPush.registerNotificationsCallback(notificationReceived);              					},
         function(failureResponse){
             alert("Failed to initialize");
         }
    );
    
  2. 实施通知回调方法。

    var notificationReceived = function(message) {
         alert(JSON.stringify(message));
    };
    
  3. 向推送通知服务注册移动设备。

    MFPPush.registerDevice(function(successResponse) {
         alert("Successfully registered");
         },
       function(failureResponse) {
         alert("Failed to register");
         }
    );
    
  4. (可选)从推送通知服务注销移动设备。

    MFPPush.unregisterDevice(function(successResponse) {
         alert("Successfully unregistered");
         },
       function(failureResponse) {
         alert("Failed to unregister");
         }
    );
    
  5. 除去 WL.Client.Push.isPushSupported()(如果已使用)并使用:

    MFPPush.isPushSupported (function(successResponse) {
         alert(successResponse);
         },
       function(failureResponse) {
         alert("Failed to get the push suport status");
         }
    );
    
  6. 除去以下 WL.Client.Push API:

    • onReadyToSubscribe()
    • onMessage()
服务器

除去适配器中的 WL.Server.sendMessage()(如果已使用)。
针对使用同一事件源的每个应用程序完成以下步骤:

  1. 使用 MobileFirst Operations Console 设置凭证。 请参阅配置推送通知设置

    您还可以对 Android 应用程序使用更新 GCM 设置 (PUT) REST API 来设置凭证,或者对 iOS 应用程序使用更新 APN 设置 (PUT) REST API 来设置凭证。

  2. 作用域元素映射中添加作用域 push.mobileclient
  3. 创建标记以支持将推送通知发送至订户。 请参阅“为推送通知定义标记”。
  4. 您可以使用以下任一方法来发送通知:

方案 4:现有应用程序在其应用中使用标签通知

客户机
  1. 初始化应用程序中的 MFPPush 客户机实例,并在成功回调中注册应接收通 知的回调方法。

    MFPPush.initialize(function(successResponse){
         MFPPush.registerNotificationsCallback(notificationReceived);              					},
         function(failureResponse){
             alert("Failed to initialize");
         }
    );
    
  2. 实施通知回调方法。

    var notificationReceived = function(message) {
         alert(JSON.stringify(message));
    };
    
  3. 向推送通知服务注册移动设备。

    MFPPush.registerDevice(function(successResponse) {
         alert("Successfully registered");
         },
       function(failureResponse) {
         alert("Failed to register");
         }
    );
    
  4. (可选)从推送通知服务注销移动设备。

    MFPPush.unregisterDevice(function(successResponse) {
         alert("Successfully unregistered");
         },
       function(failureResponse) {
         alert("Failed to unregister");
         }
    );
    
  5. 除去 WL.Client.Push.isPushSupported()(如果已使用)并使用:

    MFPPush.isPushSupported (function(successResponse) {
         alert(successResponse);
         },
       function(failureResponse) {
         alert("Failed to get the push suport status");
        }
    );
    
  6. 除去以下 WL.Client.Push API:
    • subscribeTag()
    • unsubscribeTag()
    • isTagSubscribed()
    • onReadyToSubscribe()
    • onMessage()
  7. 预订标记:

    var tags = ['sample-tag1','sample-tag2'];
    MFPPush.subscribe(tags, function(successResponse) {
         alert("Successfully subscribed");
         },
       function(failureResponse) {
         alert("Failed to subscribe");
         }
    );
    
  8. (可选)从标记取消预订:

    MFPPush.unsubscribe(tags, function(successResponse) {
         alert("Successfully unsubscribed");
         },
       function(failureResponse) {
         alert("Failed to unsubscribe");
         }
    );
    
服务器

除去适配器中的 WL.Server.sendMessage()(如果已使用)。
针对使用同一事件源的每个应用程序完成以下步骤:

  1. 使用 MobileFirst Operations Console 设置凭证。 请参阅配置推送通知设置

    您还可以对 Android 应用程序使用更新 GCM 设置 (PUT) REST API 来设置凭证,或者对 iOS 应用程序使用更新 APN 设置 (PUT) REST API 来设置凭证。

  2. 作用域元素映射中添加作用域 push.mobileclient
  3. 创建标记以支持将推送通知发送至订户。 请参阅“为推送通知定义标记”。
  4. 您可以使用以下任一方法来发送通知:

本机 Android 应用程序

迁移方案示例包括使用单一事件源或多个源、广播或者单点广播通知或标签通知的应用程序。

方案 1:现有应用程序在其应用中使用单个事件源

应用程序已在 MobileFirst 的先前版本上使用单个事件源,因为它仅通过基于事件源的模型支持推送。

客户机

要在 V8.0 中对此进行迁移,请将此模型转换为单点广播通知。

  1. 初始化应用程序中的 MFPPush 客户机实例。

    MFPPush push = MFPPush.getInstance();
         push.initialize(_this);
    
  2. 实现接口 MFPPushNotificationListener 并定义 onReceive()。

    @Override
    public void onReceive(MFPSimplePushNotification message) {
         Log.i("Push Notifications", message.getAlert());
    }
    
  3. 向推送通知服务注册移动设备。

    push.registerDevice(new MFPPushResponseListener<String>(){
         @Override
         public void onFailure(MFPPushException arg0) {
             Log.i("Push Notifications", "Failed to register");
         }
         @Override
         public void onSuccess(String arg0) {
            Log.i("Push Notifications", "Registered successfully");
    
         }
    });
    
  4. (可选)从推送通知服务注销移动设备。

    push.unregisterDevice(new MFPPushResponseListener<String>(){
         @Override
         public void onFailure(MFPPushException arg0) {
             Log.i("Push Notifications", "Failed to unregister");
    
         }
         @Override
         public void onSuccess(String arg0) {
              Log.i("Push Notifications", "Unregistered successfully");
         }
    });
    
  5. 除去 WLClient.Push.isPushSupported()(如果已使用)并使用 push.isPushSupported();
  6. 除去以下 WLClient.Push API,因为将没有要预订并用于注册通知回调的事件源:
    • registerEventSourceCallback()
    • subscribe()
    • unsubscribe()
    • isSubscribed()
    • WLOnReadyToSubscribeListenerWLNotificationListener 实现
服务器

除去适配器中的以下 WL.Server API(如果已使用):

  • notifyAllDevices()
  • notifyDevice()
  • notifyDeviceSubscription()
  • createEventSource()

针对使用同一事件源的每个应用程序完成以下步骤:

  1. 使用 MobileFirst Operations Console 设置凭证。 请参阅配置推送通知设置

    您还可以对 Android 应用程序使用更新 GCM 设置 (PUT) REST API 来设置凭证,或者对 iOS 应用程序使用更新 APN 设置 (PUT) REST API 来设置凭证。

  2. 作用域元素映射中添加作用域 push.mobileclient
  3. 创建标记以支持将推送通知发送至订户。 请参阅“为推送通知定义标记”。
  4. 您可以使用以下任一方法来发送通知:

方案 2:现有应用程序在其应用中使用多个事件源

使用多个事件源的应用程序要求基于预订对用户进行细分。

客户机

这将映射到基于相关主题对用户/设备进行分段的标记。 要将它迁移到 Mobile Foundation V8.0.0,请将此模型转换为基于标记的通知。

  1. 初始化应用程序中的 MFPPush 客户机实例:

    MFPPush push = MFPPush.getInstance();
         push.initialize(_this);
    
  2. 实现接口 MFPPushNotificationListener 并定义 onReceive()。

    @Override
    public void onReceive(MFPSimplePushNotification message) {
         Log.i("Push Notifications", message.getAlert());
    }
    
  3. 向推送通知服务注册移动设备。

    push.registerDevice(new MFPPushResponseListener<String>(){
         @Override
         public void onFailure(MFPPushException arg0) {
             Log.i("Push Notifications", "Failed to register");
         }
         @Override
         public void onSuccess(String arg0) {
             Log.i("Push Notifications", "Registered successfully");
    
         }
    });
    
  4. (可选)从推送通知服务注销移动设备:

    push.unregisterDevice(new MFPPushResponseListener<String>(){
         @Override
         public void onFailure(MFPPushException arg0) {
             Log.i("Push Notifications", "Failed to unregister");
    
         }
         @Override
         public void onSuccess(String arg0) {
             Log.i("Push Notifications", "Unregistered successfully");
         }
    });
    
  5. 除去 WLClient.Push.isPushSupported()(如果已使用)并使用 push.isPushSupported();
  6. 除去以下 WLClient.Push API,因为将没有要预订并用于注册通知回调的事件源:
    • registerEventSourceCallback()
    • subscribe()
    • unsubscribe()
    • isSubscribed()
  7. WLOnReadyToSubscribeListenerWLNotificationListener 实现
  8. 预订标记:

    String[] tags = new String[2];
    tags[0] ="sample-tag1";
    tags[1] ="sample-tag2";
    push.subscribe(tags, new MFPPushResponseListener<String[]>(){
    
         @Override
         public void onFailure(MFPPushException arg0) {
             Log.i("Failed to subscribe");
         }
    
         @Override
         public void onSuccess(String[] arg0) {
             Log.i( "Subscribed successfully");
         }
    });
    
  9. (可选)从标记取消预订:

    String[] tags = new String[2];
    tags[0] ="sample-tag1";
    tags[1] ="sample-tag2";
    push.unsubscribe(tags, new MFPPushResponseListener<String[]>(){
    
         @Override
         public void onFailure(MFPPushException arg0) {
             Log.i("Push Notifications", "Failed to unsubscribe");
         }
    
         @Override
         public void onSuccess(String[] arg0) {
             Log.i("Push Notifications", "Unsubscribed successfully");
         }
    });
    
服务器

除去适配器中的以下 WL.Server API(如果已使用):

  • notifyAllDevices()
  • notifyDevice()
  • notifyDeviceSubscription()
  • createEventSource()

针对使用同一事件源的每个应用程序完成以下步骤:

  1. 使用 MobileFirst Operations Console 设置凭证。 请参阅配置推送通知设置

    您还可以对 Android 应用程序使用更新 GCM 设置 (PUT) REST API 来设置凭证,或者对 iOS 应用程序使用更新 APN 设置 (PUT) REST API 来设置凭证。

  2. 作用域元素映射中添加作用域 push.mobileclient
  3. 创建标记以支持将推送通知发送至订户。 请参阅“为推送通知定义标记”。
  4. 您可以使用以下任一方法来发送通知:

方案 3:现有应用程序在其应用中使用广播/单点广播通知

客户机
  1. 初始化应用程序中的 MFPPush 客户机实例:

    MFPPush push = MFPPush.getInstance();
         push.initialize(_this);
    
  2. 实施接口 MFPPushNotificationListener 并定义 onReceive()

    @Override
    public void onReceive(MFPSimplePushNotification message) {
         Log.i("Push Notifications", message.getAlert());
    }
    
  3. 向推送通知服务注册移动设备。

    push.registerDevice(new MFPPushResponseListener<String>(){
         @Override
         public void onFailure(MFPPushException arg0) {
             Log.i("Push Notifications", "Failed to register");
         }
         @Override
         public void onSuccess(String arg0) {
             Log.i("Push Notifications", "Registered successfully");
    
         }
    });
    
  4. (可选)从推送通知服务注销移动设备。

    push.unregisterDevice(new MFPPushResponseListener<String>(){
         @Override
         public void onFailure(MFPPushException arg0) {
             Log.i("Push Notifications", "Failed to unregister");
    
         }
         @Override
         public void onSuccess(String arg0) {
             Log.i("Push Notifications", "Unregistered successfully");
         }
    });
    
  5. 除去 WLClient.Push.isPushSupported()(如果已使用)并使用 push.isPushSupported();
  6. 除去以下 WLClient.Push API:
    • registerEventSourceCallback()
    • WLOnReadyToSubscribeListenerWLNotificationListener 实现
服务器

除去适配器中的 WL.Server.sendMessage()` API(如果已使用):

针对使用同一事件源的每个应用程序完成以下步骤:

  1. 使用 MobileFirst Operations Console 设置凭证。 请参阅配置推送通知设置

    您还可以对 Android 应用程序使用更新 GCM 设置 (PUT) REST API 来设置凭证,或者对 iOS 应用程序使用更新 APN 设置 (PUT) REST API 来设置凭证。

  2. 作用域元素映射中添加作用域 push.mobileclient
  3. 创建标记以支持将推送通知发送至订户。 请参阅“为推送通知定义标记”。
  4. 您可以使用以下任一方法来发送通知:

方案 4:现有应用程序在其应用中使用标签通知

客户机
  1. 初始化应用程序中的 MFPPush 客户机实例:

    MFPPush push = MFPPush.getInstance();
         push.initialize(_this);
    
  2. 实现接口 MFPPushNotificationListener 并定义 onReceive()。

    @Override
    public void onReceive(MFPSimplePushNotification message) {
         Log.i("Push Notifications", message.getAlert());
    }
    
  3. 向推送通知服务注册移动设备。

    push.registerDevice(new MFPPushResponseListener<String>(){
         @Override
         public void onFailure(MFPPushException arg0) {
             Log.i("Push Notifications", "Failed to register");
         }
         @Override
         public void onSuccess(String arg0) {
             Log.i("Push Notifications", "Registered successfully");
    
         }
    });
    
  4. (可选)从推送通知服务注销移动设备。

    push.unregisterDevice(new MFPPushResponseListener<String>(){
         @Override
         public void onFailure(MFPPushException arg0) {
             Log.i("Push Notifications", "Failed to unregister");
    
         }
         @Override
         public void onSuccess(String arg0) {
             Log.i("Push Notifications", "Unregistered successfully");
         }
    });
    
  5. 除去 WLClient.Push.isPushSupported()(如果已使用)并使用 push.isPushSupported()
  6. 除去以下 WLClient.Push API:
    • subscribeTag()
    • unsubscribeTag()
    • isTagSubscribed()
    • WLOnReadyToSubscribeListenerWLNotificationListener 实现
  7. 预订标记:

    String[] tags = new String[2];
    tags[0] ="sample-tag1";
    tags[1] ="sample-tag2";
    push.subscribe(tags, new MFPPushResponseListener<String[]>(){
    
         @Override
         public void onFailure(MFPPushException arg0) {
             Log.i("Failed to subscribe");
         }
    
         @Override
         public void onSuccess(String[] arg0) {
             Log.i( "Subscribed successfully");
         }
    });
    
  8. (可选)从标记取消预订:

    String[] tags = new String[2];
    tags[0] ="sample-tag1";
    tags[1] ="sample-tag2";
    push.unsubscribe(tags, new MFPPushResponseListener<String[]>(){
    
         @Override
         public void onFailure(MFPPushException arg0) {
             Log.i("Push Notifications", "Failed to unsubscribe");
         }
    
         @Override
         public void onSuccess(String[] arg0) {
             Log.i("Push Notifications", "Unsubscribed successfully");
         }
    });
    
服务器

除去适配器中的 WL.Server.sendMessage()(如果已使用)。

针对使用同一事件源的每个应用程序完成以下步骤:

  1. 使用 MobileFirst Operations Console 设置凭证。 请参阅配置推送通知设置

    您还可以对 Android 应用程序使用更新 GCM 设置 (PUT) REST API 来设置凭证,或者对 iOS 应用程序使用更新 APN 设置 (PUT) REST API 来设置凭证。

  2. 作用域元素映射中添加作用域 push.mobileclient
  3. 创建标记以支持将推送通知发送至订户。 请参阅“为推送通知定义标记”。
  4. 您可以使用以下任一方法来发送通知:

本机 iOS 应用程序

迁移方案示例包括使用单一事件源或多个源、广播或者单点广播通知或标签通知的应用程序。

方案 1:现有应用程序在其应用中使用单个事件源

应用程序已在 MobileFirst 的较早版本上使用单个事件源,因为它仅通过基于事件源的模型支持推送。

客户机

要在 V8.0 中对此进行迁移,请将此模型转换为单点广播通知。

  1. 初始化应用程序中的 MFPPush 客户机实例。

    [[MFPPush sharedInstance] initialize];
    
  2. didReceiveRemoteNotification() 中实施通知处理。
  3. 向推送通知服务注册移动设备。

    [[MFPPush sharedInstance] registerDevice:^(WLResponse *response, NSError *error) {
         if(error){
     	   NSLog(@"Failed to register");
         } else {
             NSLog(@"Successfullyregistered");
         }
    }];
    
  4. (可选)从推送通知服务注销移动设备。

    [MFPPush sharedInstance] unregisterDevice:^(WLResponse *response, NSError *error) {
         if(error){
            NSLog(@"Failed to unregister");
         } else {
            NSLog(@"Successfully unregistered");
         }
    }];
    
  5. 除去 WLClient.Push.isPushSupported()(如果已使用)并使用:

    [[MFPPush sharedInstance] isPushSupported]
    
  6. 除去以下 WLClient.Push API,因为将没有要预订并用于注册通知回调的事件源:
    • registerEventSourceCallback()
    • subscribe()
    • unsubscribe()
    • isSubscribed()
    • WLOnReadyToSubscribeListener 实施
  7. didRegisterForRemoteNotificationsWithDeviceToken 中调用 sendDeviceToken()

    [[MFPPush sharedInstance] sendDeviceToken:deviceToken];
    
服务器

除去适配器中的以下 WL.Server API(如果已使用):

  • notifyAllDevices()
  • notifyDevice()
  • notifyDeviceSubscription()
  • createEventSource()

针对使用同一事件源的每个应用程序完成以下步骤:

  1. 使用 MobileFirst Operations Console 设置凭证。 请参阅配置推送通知设置

    您还可以对 Android 应用程序使用更新 GCM 设置 (PUT) REST API 来设置凭证,或者对 iOS 应用程序使用更新 APN 设置 (PUT) REST API 来设置凭证。

  2. 作用域元素映射中添加作用域 push.mobileclient
  3. 创建标记以支持将推送通知发送至订户。 请参阅“为推送通知定义标记”。
  4. 您可以使用以下任一方法来发送通知:

方案 2:现有应用程序在其应用中使用多个事件源

使用多个事件源的应用程序要求基于预订对用户进行细分。

客户机

这将映射到基于相关主题对用户/设备进行分段的标记。 要将它迁移到 MobileFirst V8.0.0,请将此模型转换为基于标记的通知。

  1. 初始化应用程序中的 MFPPush 客户机实例。

    [[MFPPush sharedInstance] initialize];
    
  2. didReceiveRemoteNotification() 中实施通知处理。
  3. 向推送通知服务注册移动设备:

    [[MFPPush sharedInstance] registerDevice:^(WLResponse *response, NSError *error) {
         if(error){
         	NSLog(@"Failed to register");
         }else{
         	NSLog(@"Successfullyregistered");
         }
    }];
    
  4. (可选)从推送通知服务注销移动设备:

    [MFPPush sharedInstance] unregisterDevice:^(WLResponse *response, NSError *error) {
         if(error){
         	NSLog(@"Failed to unregister");
         }else{
         	NSLog(@"Successfully unregistered");
         }
    }];
    
  5. 除去 WLClient.Push.isPushSupported()(如果已使用)并使用:

    [[MFPPush sharedInstance] isPushSupported]
    
  6. 除去以下 WLClient.Push API,因为将没有要预订并用于注册通知回调的事件源:
    • registerEventSourceCallback()
    • subscribe()
    • unsubscribe()
    • isSubscribed()
    • WLOnReadyToSubscribeListener 实施
  7. didRegisterForRemoteNotificationsWithDeviceToken 中调用 sendDeviceToken()
  8. 预订标记:

    NSMutableArray *tags = [[NSMutableArray alloc]init];
    [tags addObject:@"sample-tag1"];
    [tags addObject:@"sample-tag2"];
    [MFPPush sharedInstance] subscribe:tags completionHandler:^(WLResponse *response, NSError *error) {
         if(error){
         	NSLog(@"Failed to unregister");
         }else{
         	NSLog(@"Successfully unregistered");
         }
    }];
    
  9. (可选)从标记取消预订:

    NSMutableArray *tags = [[NSMutableArray alloc]init];
    [tags addObject:@"sample-tag1"];
    [tags addObject:@"sample-tag2"];
    [MFPPush sharedInstance] unsubscribe:tags completionHandler:^(WLResponse *response, NSError *error) {
         if(error){
         	NSLog(@"Failed to unregister");
         }else{
         	NSLog(@"Successfully unregistered");
         }
    }];
    
服务器

:{: #server-ios-2 } 除去适配器中的 WL.Server(如果已使用)。

  • notifyAllDevices()
  • notifyDevice()
  • notifyDeviceSubscription()
  • createEventSource()

针对使用同一事件源的每个应用程序完成以下步骤:

  1. 使用 MobileFirst Operations Console 设置凭证。 请参阅配置推送通知设置

    您还可以对 Android 应用程序使用更新 GCM 设置 (PUT) REST API 来设置凭证,或者对 iOS 应用程序使用更新 APN 设置 (PUT) REST API 来设置凭证。

  2. 作用域元素映射中添加作用域 push.mobileclient
  3. 创建标记以支持将推送通知发送至订户。 请参阅“为推送通知定义标记”。
  4. 您可以使用以下任一方法来发送通知:

方案 3:现有应用程序在其应用中使用广播/单点广播通知

客户机
  1. 初始化应用程序中的 MFPPush 客户机实例:

    [[MFPPush sharedInstance] initialize];
    
  2. didReceiveRemoteNotification() 中实施通知处理。
  3. 向推送通知服务注册移动设备:

    [[MFPPush sharedInstance] registerDevice:^(WLResponse *response, NSError *error) {
         if(error){
         	NSLog(@"Failed to register");
         }else{
         	NSLog(@"Successfullyregistered");
         }
    }];
    
  4. (可选)从推送通知服务注销移动设备。

    [MFPPush sharedInstance] unregisterDevice:^(WLResponse *response, NSError *error) {
         if(error){
         	NSLog(@"Failed to unregister");
         }else{
         	NSLog(@"Successfully unregistered");
         }
    }];
    
  5. 除去 WLClient.Push.isPushSupported()(如果已使用)并使用:

    [[MFPPush sharedInstance] isPushSupported]
    
  6. 除去以下 WLClient.Push API:
    • registerEventSourceCallback()
    • WLOnReadyToSubscribeListener 实施
服务器

除去适配器中的 WL.Server.sendMessage(如果已使用)。

针对使用同一事件源的每个应用程序完成以下步骤:

  1. 使用 MobileFirst Operations Console 设置凭证。 请参阅配置推送通知设置

    您还可以对 Android 应用程序使用更新 GCM 设置 (PUT) REST API 来设置凭证,或者对 iOS 应用程序使用更新 APN 设置 (PUT) REST API 来设置凭证。

  2. 作用域元素映射中添加作用域 push.mobileclient
  3. 创建标记以支持将推送通知发送至订户。 请参阅“为推送通知定义标记”。
  4. 您可以使用以下任一方法来发送通知:

方案 4:现有应用程序在其应用中使用标签通知

客户机
  1. 初始化应用程序中的 MFPPush 客户机实例:

    [[MFPPush sharedInstance] initialize];
    
  2. didReceiveRemoteNotification() 中实施通知处理。
  3. 向推送通知服务注册移动设备:

    [[MFPPush sharedInstance] registerDevice:^(WLResponse *response, NSError *error) {
         if(error){
         	NSLog(@"Failed to register");
         }else{
         	NSLog(@"Successfullyregistered");
         }
    }];
    
  4. (可选)从推送通知服务注销移动设备:

    [MFPPush sharedInstance] unregisterDevice:^(WLResponse *response, NSError *error) {
         if(error){
         	NSLog(@"Failed to unregister");
         }else{
         	NSLog(@"Successfully unregistered");
         }
    }];
    
  5. 除去 WLClient.Push.isPushSupported()(如果已使用)并使用 [[MFPPush sharedInstance] isPushSupported]
  6. 除去以下 WLClient.Push API,因为将没有要预订并用于注册通知回调的事件源:
    • registerEventSourceCallback()
    • subscribeTag()
    • unsubscribeTag()
    • isTagSubscribed()
    • WLOnReadyToSubscribeListener 实施
  7. didRegisterForRemoteNotificationsWithDeviceToken 中调用 sendDeviceToken()
  8. 预订标记:

    NSMutableArray *tags = [[NSMutableArray alloc]init];
    [tags addObject:@"sample-tag1"];
    [tags addObject:@"sample-tag2"];
    [MFPPush sharedInstance] subscribe:tags completionHandler:^(WLResponse *response, NSError *error) {
         if(error){
            NSLog(@"Failed to unregister");
         } else {    
            NSLog(@"Successfully unregistered");
         }
    }];
    
  9. (可选)从标记取消预订:

    NSMutableArray *tags = [[NSMutableArray alloc]init];
    [tags addObject:@"sample-tag1"];
    [tags addObject:@"sample-tag2"];
    [MFPPush sharedInstance] unsubscribe:tags completionHandler:^(WLResponse *response, NSError *error) {
         if(error){
         	NSLog(@"Failed to unregister");
         }else{
         	NSLog(@"Successfully unregistered");
         }
    }];
    
服务器

除去适配器中的以下 WL.Server.sendMessage()(如 果已使用)。

针对使用同一事件源的每个应用程序完成以下步骤:

  1. 使用 MobileFirst Operations Console 设置凭证。 请参阅配置推送通知设置

    您还可以对 Android 应用程序使用更新 GCM 设置 (PUT) REST API 来设置凭证,或者对 iOS 应用程序使用更新 APN 设置 (PUT) REST API 来设置凭证。

  2. 作用域元素映射中添加作用域 push.mobileclient
  3. 创建标记以支持将推送通知发送至订户。 请参阅“为推送通知定义标记”。
  4. 您可以使用以下任一方法来发送通知:

本机 Windows Universal 应用程序

迁移方案示例包括使用单一事件源或多个源、广播或者单点广播通知或标签通知的应用程序。

方案 1:现有应用程序在其应用中使用单个事件源

要在 V8.0 中对此进行迁移,请将此模型转换为单点广播通知。

客户机
  1. 初始化应用程序中的 MFPPush 客户机实例。

    MFPPush push = MFPPush.GetInstance();
    push.Initialize();
    Implement the interface MFPPushNotificationListener and define onReceive().
    class Pushlistener : MFPPushNotificationListener
    {
         public void onReceive(String properties, String payload)
         {
                 Debug.WriteLine("Push Notifications\n properties:" + properties + "\n payload:" + payload);
         }
    }
    
  2. 向推送通知服务注册移动设备。

    MFPPushMessageResponse Response = await push.RegisterDevice(null);
    if (Response.Success == true)
    {
         Debug.WriteLine("Push Notifications Registered successfully");
    }
    else
    {
         Debug.WriteLine("Push Notifications Failed to register");
    }
    
  3. (可选)从推送通知服务注销移动设备。

    MFPPushMessageResponse Response = await push.UnregisterDevice();
    if (Response.Success == true)
    {
         Debug.WriteLine("Push Notifications Failed to unregister");
    }
    else
    {
         Debug.WriteLine("Push Notifications Unregistered successfully");
    }
    
  4. 除去 WLClient.Push.IsPushSupported()(如果已使用)并使用 push.IsPushSupported();
  5. 除去以下 WLClient.Push API,因为将没有要预订并用于注册通知回调的事件源:
    • registerEventSourceCallback()
    • subscribe()
    • unsubscribe()
    • isSubscribed()
    • WLOnReadyToSubscribeListenerWLNotificationListener 实现
服务器

除去适配器中的以下 WL.Server API(如果已使用):

  • notifyAllDevices()
  • notifyDevice()
  • notifyDeviceSubscription()
  • createEventSource()

针对使用同一事件源的每个应用程序完成以下步骤:

  1. 在 MobileFirst Operations Console 的推送设置页面中设置 WNS 凭证或使用 WNS 设置 REST API。
  2. 映射作用域元素中的作用域 push.mobileclient 添加到 MobileFirst Operations Console 的“安全性”选项卡的安全性检查部分中。
  3. 您还可将推送消息 (POST) REST API 与 userId/deviceId 配合使用来发送消息。

方案 2:现有应用程序在其应用中使用多个事件源

使用多个事件源的应用程序要求基于预订对用户进行细分。

客户机

这将映射到基于相关主题对用户/设备进行分段的标记。 要将它迁移到 MobileFirst V8.0.0,请将此模型转换为基于标记的通知。

  1. 初始化应用程序中的 MFPPush 客户机实例:

    MFPPush push = MFPPush.GetInstance();
    push.Initialize();
    Implement the interface MFPPushNotificationListener and define onReceive().
    class Pushlistener : MFPPushNotificationListener
    {
         public void onReceive(String properties, String payload)
         {
                 Debug.WriteLine("Push Notifications\n properties:" + properties + "\n payload:" + payload);
         }
    }
    
  2. 向 IMFPUSH 服务注册移动设备。

    MFPPushMessageResponse Response = await push.RegisterDevice(null);
    if (Response.Success == true)
    {
         Debug.WriteLine("Push Notifications Registered successfully");
    }
    else
    {
         Debug.WriteLine("Push Notifications Failed to register");
    }
    
  3. (可选)从 IMFPUSH 服务注销移动设备:

    MFPPushMessageResponse Response = await push.UnregisterDevice();
    if (Response.Success == true)
    {
         Debug.WriteLine("Push Notifications Failed to unregister");
    }
    else
    {
         Debug.WriteLine("Push Notifications Unregistered successfully");
    }
    
  4. 除去 WLClient.Push.IsPushSupported()(如果已使用)并使用 push.IsPushSupported();
  5. 除去以下 WLClient.Push API,因为将没有要预订并用于注册通知回调的事件源:
    • registerEventSourceCallback()
    • subscribe()
    • unsubscribe()
    • isSubscribed()
    • WLOnReadyToSubscribeListenerWLNotificationListener 实现
  6. 预订标记:

    String[] Tag = { "sample-tag1", "sample-tag2" };
    MFPPushMessageResponse Response = await push.Subscribe(Tag);
    if (Response.Success == true)
    {
         Debug.WriteLine("Subscribed successfully");
    }
    else
    {
         Debug.WriteLine("Failed to subscribe");
    }
    
  7. (可选)从标记取消预订:

    String[] Tag = { "sample-tag1", "sample-tag2" };
    MFPPushMessageResponse Response = await push.Unsubscribe(Tag);
    if (Response.Success == true)
    {
         Debug.WriteLine("Unsubscribed successfully");
    }
    else
    {
         Debug.WriteLine("Failed to unsubscribe");
    }
    
服务器

除去适配器中的以下 WL.Server API(如果已使用):

  • notifyAllDevices()
  • notifyDevice()
  • notifyDeviceSubscription()
  • createEventSource()

针对使用同一事件源的每个应用程序完成以下步骤:

  1. 在 MobileFirst Operations Console 的推送设置页面中设置 WNS 凭证或使用 WNS 设置 REST API。
  2. 映射作用域元素中的作用域 push.mobileclient 添加到 MobileFirst Operations Console 的安全性选项卡的安全性检查部分中。
  3. 在 MobileFirst Operations Console 的标记页面中创建推送标记。
  4. 您还可将推送消息 (POST) REST API 与 userId/deviceId/tagNames(作为目标)配合使用来发送通知。

方案 3:现有应用程序在其应用中使用广播/单点广播通知

客户机
  1. 初始化应用程序中的 MFPPush 客户机实例:

    MFPPush push = MFPPush.GetInstance();
    push.Initialize();
    Implement the interface MFPPushNotificationListener and define onReceive().
    class Pushlistener : MFPPushNotificationListener
    {
         public void onReceive(String properties, String payload)
         {
                 Debug.WriteLine("Push Notifications\n properties:" + properties + "\n payload:" + payload);
         }
    }
    
  2. 向推送通知服务注册移动设备。

    MFPPushMessageResponse Response = await push.RegisterDevice(null);
    if (Response.Success == true)
    {
         Debug.WriteLine("Push Notifications Registered successfully");
    }
    else
    {
         Debug.WriteLine("Push Notifications Failed to register");
    }
    
  3. (可选)从推送通知服务注销移动设备。

    MFPPushMessageResponse Response = await push.UnregisterDevice();
    if (Response.Success == true)
    {
         Debug.WriteLine("Push Notifications Failed to unregister");
    }
    else
    {
         Debug.WriteLine("Push Notifications Unregistered successfully");
    }
    
  4. 除去 WLClient.Push.isPushSupported()(如果已使用)并使用 push.IsPushSupported();
  5. 除去以下 WLClient.Push API:
    • registerEventSourceCallback()
    • WLOnReadyToSubscribeListenerWLNotificationListener 实现
服务器

除去适配器中的 WL.Server.sendMessage()(如果已使用)。

针对使用同一事件源的每个应用程序完成以下步骤:

  1. 在 MobileFirst Operations Console 的推送设置页面中设置 WNS 凭证或使用 WNS 设置 REST API。
  2. 映射作用域元素中的作用域 push.mobileclient 添加到 MobileFirst Operations Console 的安全性选项卡的安全性检查部分中。
  3. 在 MobileFirst Operations Console 的标记页面中创建推送标记。
  4. 您还可将推送消息 (POST) REST API 与 userId/deviceId/tagNames(作为目标)配合使用来发送通知。

方案 4:现有应用程序在其应用中使用标签通知

客户机
  1. 初始化应用程序中的 MFPPush 客户机实例:

    MFPPush push = MFPPush.GetInstance();
    push.Initialize();
    
  2. 实现接口 MFPPushNotificationListener 并定义 onReceive()。

    class Pushlistener : MFPPushNotificationListener
    {
         public void onReceive(String properties, String payload)
         {
                 Debug.WriteLine("Push Notifications\n properties:" + properties + "\n payload:" + payload);
         }
    }
    
  3. 向推送通知服务注册移动设备。

    MFPPushMessageResponse Response = await push.RegisterDevice(null);
    if (Response.Success == true)
    {
         Debug.WriteLine("Push Notifications Registered successfully");
    }
    else
    {
         Debug.WriteLine("Push Notifications Failed to register");
    }
    
  4. (可选)从推送通知服务注销移动设备。

    MFPPushMessageResponse Response = await push.UnregisterDevice();
    if (Response.Success == true)
    {
         Debug.WriteLine("Push Notifications Failed to unregister");
    }
    else
    {
         Debug.WriteLine("Push Notifications Unregistered successfully");
    }
    
  5. 除去 WLClient.Push.IsPushSupported()(如果已使用)并使用 push.IsPushSupported()
  6. 除去以下 WLClient.Push API:
    • subscribeTag()
    • unsubscribeTag()
    • isTagSubscribed()
    • WLOnReadyToSubscribeListenerWLNotificationListener 实现
  7. 预订标记:

    String[] Tag = { "sample-tag1", "sample-tag2" };
    MFPPushMessageResponse Response = await push.Subscribe(Tag);
    if (Response.Success == true)
    {
         Debug.WriteLine("Subscribed successfully");
    }
    else
    {
         Debug.WriteLine("Failed to subscribe");
    }
    
  8. (可选)从标记取消预订:

    String[] Tag = { "sample-tag1", "sample-tag2" };
    MFPPushMessageResponse Response = await push.Unsubscribe(Tag);
    if (Response.Success == true)
    {
         Debug.WriteLine("Unsubscribed successfully");
    }
    else
    {
         Debug.WriteLine("Failed to unsubscribe");
    }
    
服务器

除去适配器中的 WL.Server.sendMessage()(如果已使用)。

针对使用同一事件源的每个应用程序完成以下步骤:

  1. 在 MobileFirst Operations Console 的推送设置页面中设置 WNS 凭证或使用 WNS 设置 REST API。
  2. 映射作用域元素中的作用域 push.mobileclient 添加到 MobileFirst Operations Console 的安全性选项卡的安全性检查部分中。
  3. 在 MobileFirst Operations Console 的标记页面中创建推送标记。
  4. 您还可将推送消息 (POST) REST API 与 userId/deviceId/tagNames(作为目标)配合使用来发送通知。

迁移工具

此迁移工具可帮助将 MobileFirst Platform Foundation 7.1 推送数据(设备、用户预订、凭证和标记)迁移到 Mobile Foundation 8.0。
迁移工具可通过以下功能简化此过程:

  1. 从 MobileFirst Platform Foundation 7.1 数据库中读取每个应用程序的设备、凭证、标记和用户预订。
  2. 将数据复制到 Mobile Foundation 8.0 数据库中各个应用程序的相应表格中。
  3. 迁移所有 V7.1 环境的所有推送数据,而不考虑 V8.0 应用程序中的环境。

迁移工具将不会修改与用户预订、应用程序环境或设备相关的任何数据。

使用迁移工具之前,请务必了解以下信息:

  1. 您必须已安装 Java V1.6 或更高版本。
  2. 确保 MobileFirst Server 7.1 和 MobileFirst Server 8.0 均已设置并准备就绪。
  3. 生成 MobileFirst Server 7.1 和 MobileFirst Server 8.0 的备份。
  4. 在 MobileFirst Server 8.0 中注册以上应用程序的最新版本。
    • 应用程序的显示名称应与 MobileFirst Platform Foundation 7.1 中相应的应用程序相匹配。
    • 请记住 PacakgeName/BundleID,并为应用程序提供相同的值。
    • 如果在 MobileFirst Server 8.0 上未注册该应用程序,那么迁移将失败。
  5. 为应用程序的每个环境提供作用域-元素映射。 了解有关作用域映射的更多信息

过程

  1. 以下 GitHub 存储库下载迁移工具。
  2. 下载该工具后,在 migration.properties 文件中提供以下详细信息:

    描述 样本值
    w.db.type 考虑中的数据库类型 pw.db.type = db2 可能的值:DB2、Oracle、MySql 或 Derby
    pw.db.url MobileFirst Platform Foundation 7.1 Worklight DB URL jdbc:mysql://localhost:3306/WRKLGHT
    pw.db.adminurl MobileFirst Platform Foundation 7.1 Admin DB URL jdbc:mysql://localhost:3306/ADMIN
    pw.db.username MobileFirst Platform Foundation 7.1 Worklight DB 用户名 pw.db.username=root
    pw.db.password MobileFirst Platform Foundation 7.1 Worklight DB 密码 pw.db.password=root
    pw.db.adminusername MobileFirst Platform Foundation 7.1 Admin DB 用户名 pw.db.adminusername=root
    pw.db.adminpassword MobileFirst Platform Foundation 7.1 Admin DB 密码 pw.db.adminpassword=root
    pw.db.urlTarget MFP 8.0 DB URL jdbc:mysql://localhost:3306/MFPDATA
    pw.db.usernameTarget MFP 8.0 DB 用户名 pw.db.usernameTarget=root
    pw.db.passwordTarget MFP 8.0 DB 密码 pw.db.passwordTarget=root
    pw.db.schema MobileFirst Platform Foundation 7.1 Worklight DB 模式 WRKLGT
    pw.db.adminschema MobileFirst Platform Foundation 7.1 Admin DB 模式 WLADMIN
    pw.db.targetschema Mobile Foundation 8.0 Worklight DB 模式 MFPDATA
    runtime MobileFirst Platform Foundation 7.1 Runtime 名称 runtime=worklight
    applicationId 提供 MobileFirst Platform Foundation 7.1 上注册的应用程序列表(用逗号 (,) 分隔) HybridTestApp,NativeiOSTestApp
    targetApplicationId 提供 Mobile Foundation 8.0 上注册的应用程序列表(用逗号 (,) 分隔) com.HybridTestApp,com.NativeiOSTestApp
    • 确保已按正确的顺序提供 applicationIDtargetApplicationId 的值。 将采用 1-1(或 n-n)方式执行映射,即 applicationId 列表中第一个应用程序的数据将迁移到 targetApplicationId 列表中的第一个应用程序。
    • targetApplicationId 列表中,提供应用程序的 packageName/BundleId。 即,对于 MobileFirst Platform Foundation 7.1 中的 TestApp1,targetApplicationId 将作为 TestApp1 的 packageName/BundleId(即 com.TestApp1)。 这是因为在 MobileFirst Platform Foundation 7.1 中,applicationId 是应用程序名称,在 MobileFirst Server 8.0 中,它是基于应用程序环境的 packageName/BundleId/packageIdentityName。
  3. 通过使用以下命令来运行该工具:

    java -jar mfp-push-data-migration.jar path-to-migration.properties
    
    • 如果工具 .jar 文件与属性文件位于不同位置,请将 path-to-migration.properties 替换为指向 migration.properties 的路径。 否则,请从该命令中除去路径。

    *将包含所需库的 lib 文件夹存储在与工具 .jar 文件相同的位置中。

Inclusive terminology note: The Mobile First Platform team is making changes to support the IBM® initiative to replace racially biased and other discriminatory language in our code and content with more inclusive language. While IBM values the use of inclusive language, terms that are outside of IBM's direct influence are sometimes required for the sake of maintaining user understanding. As other industry leaders join IBM in embracing the use of inclusive language, IBM will continue to update the documentation to reflect those changes.
Last modified on June 01, 2020